From f70386820e5ad4f9329e8396b547ded16cf199e0 Mon Sep 17 00:00:00 2001 From: Thomas De Maet <thomas.demaet@uclouvain.be> Date: Wed, 9 Nov 2011 17:23:46 +0000 Subject: [PATCH] Terrestrial stuff + (int) to avoid warnings + wrangler for setArgument (expected field size checked) --- Mesh/Levy3D.cpp | 2 +- Mesh/highOrderSmoother.cpp | 4 ++-- Mesh/highOrderTools.cpp | 2 +- Mesh/meshGFaceBoundaryLayers.cpp | 2 +- Mesh/meshGRegionMMG3D.cpp | 2 +- Solver/function.cpp | 33 +++++++++++++++++++++++++++++++- Solver/function.h | 2 ++ Solver/multiscaleLaplace.cpp | 2 +- 8 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Mesh/Levy3D.cpp b/Mesh/Levy3D.cpp index de952bea60..e6d88c023a 100755 --- a/Mesh/Levy3D.cpp +++ b/Mesh/Levy3D.cpp @@ -1037,7 +1037,7 @@ void LpSmoother::improve_region(GRegion* gr){ interior_vertices.push_back(*it); } } - printf("%d\n",interior_vertices.size()); + printf("%d\n", (int) interior_vertices.size()); deleter(gr); //std::vector<GRegion*> regions; diff --git a/Mesh/highOrderSmoother.cpp b/Mesh/highOrderSmoother.cpp index 65a335a661..e5b1b74598 100644 --- a/Mesh/highOrderSmoother.cpp +++ b/Mesh/highOrderSmoother.cpp @@ -328,7 +328,7 @@ void addOneLayer(const std::vector<MElement*> &v, void _printJacobiansAtNodes (const char * name, std::vector<MElement*> &v) { FILE *fd = fopen (name,"w"); - fprintf(fd,"$MeshFormat\n2 0 8\n$EndMeshFormat\n$ElementNodeData\n1\n\"det J\"\n1\n0.0\n3\n1\n1\n%d\n",v.size()); + fprintf(fd,"$MeshFormat\n2 0 8\n$EndMeshFormat\n$ElementNodeData\n1\n\"det J\"\n1\n0.0\n3\n1\n1\n%d\n", (int) v.size()); for (int i=0; i<v.size(); i++){ const polynomialBasis* pb = v[i]->getFunctionSpace(); fprintf(fd,"%d %d",v[i]->getNum(),v[i]->getNumVertices()); @@ -723,7 +723,7 @@ double highOrderSmoother::apply_incremental_displacement (double max_incr, //+++++++++ Move vertices @ maximum ++++++++++++++++++++++++++++++++++++ FILE *fd = fopen ("d.msh","w"); - fprintf(fd,"$MeshFormat\n2 0 8\n$EndMeshFormat\n$NodeData\n1\n\"tr(sigma)\"\n1\n0.0\n3\n1\n3\n%d\n",_vertices.size()); + fprintf(fd,"$MeshFormat\n2 0 8\n$EndMeshFormat\n$NodeData\n1\n\"tr(sigma)\"\n1\n0.0\n3\n1\n3\n%d\n", (int) _vertices.size()); for (std::set<MVertex*>::iterator it = _vertices.begin(); it != _vertices.end(); ++it){ double ax, ay, az; myAssembler.getDofValue(*it, 0, getTag(), ax); diff --git a/Mesh/highOrderTools.cpp b/Mesh/highOrderTools.cpp index 3c01df8b9a..730c704095 100644 --- a/Mesh/highOrderTools.cpp +++ b/Mesh/highOrderTools.cpp @@ -619,7 +619,7 @@ double highOrderTools::apply_incremental_displacement (double max_incr, //+++++++++ Move vertices @ maximum ++++++++++++++++++++++++++++++++++++ FILE *fd = fopen ("d.msh","w"); - fprintf(fd,"$MeshFormat\n2 0 8\n$EndMeshFormat\n$NodeData\n1\n\"tr(sigma)\"\n1\n0.0\n3\n1\n3\n%d\n",_vertices.size()); + fprintf(fd,"$MeshFormat\n2 0 8\n$EndMeshFormat\n$NodeData\n1\n\"tr(sigma)\"\n1\n0.0\n3\n1\n3\n%d\n", (int) _vertices.size()); for (std::set<MVertex*>::iterator it = _vertices.begin(); it != _vertices.end(); ++it){ double ax, ay, az; myAssembler.getDofValue(*it, 0, _tag, ax); diff --git a/Mesh/meshGFaceBoundaryLayers.cpp b/Mesh/meshGFaceBoundaryLayers.cpp index d6dffcf635..3cb65b70ec 100644 --- a/Mesh/meshGFaceBoundaryLayers.cpp +++ b/Mesh/meshGFaceBoundaryLayers.cpp @@ -333,7 +333,7 @@ BoundaryLayerColumns* buidAdditionalPoints2D (GFace *gf, double _treshold) { if (blf->current_closest != catt || blf -> current_distance < _current_distance){ SVector3 aaa (_close- blf->_closest_point); if (aaa.norm() > 8*blf->hwall_n || blf -> current_distance < _current_distance){ - printf("reaching the skelton %d\n",_column.size()); + printf("reaching the skelton %d\n", (int) _column.size()); delete _column[_column.size()-1]; _column.erase(--_column.end()); _metrics.erase(--_metrics.end()); diff --git a/Mesh/meshGRegionMMG3D.cpp b/Mesh/meshGRegionMMG3D.cpp index bcfc5e3759..720b1ebcca 100644 --- a/Mesh/meshGRegionMMG3D.cpp +++ b/Mesh/meshGRegionMMG3D.cpp @@ -107,7 +107,7 @@ void gmsh2MMG (GRegion *gr, MMG_pMesh mmg, MMG_pSol sol, std::map<int,MVertex*> } } - printf("%d vertices %d on faces\n",allVertices.size(), LCS.size()); + printf("%d vertices %d on faces\n", (int) allVertices.size(), (int) LCS.size()); int k=1; int count = 1;//sol->offset; diff --git a/Solver/function.cpp b/Solver/function.cpp index b30c9aa9b6..0efc3a365a 100644 --- a/Solver/function.cpp +++ b/Solver/function.cpp @@ -42,6 +42,14 @@ void function::setArgument(fullMatrix<double> &v, const function *f, int iMap) } } +void function::setArgumentWrapped(fullMatrix<double> &v, const function *f, int expectedNbCol, std::string funcName, int iMap) +{ + if(f != function::getSolution() && f != function::getSolutionGradient() && f != function::getNormals()) + if(f->getNbCol() != expectedNbCol) + Msg::Fatal("Wrong number of expected outputs in %s (%d, expected %d)", funcName.c_str(), f->getNbCol(), expectedNbCol); + setArgument(v, f, iMap); +} + functionConstant *function::_timeFunction = NULL; functionConstant *function::_dtFunction = NULL; functionConstant *function::_dtSubFunction = NULL; @@ -642,6 +650,29 @@ function *functionScaleNew(const function *f0, const double s) { return new functionScale (f0, s); } +// functionAbs + +class functionAbs : public function { + public: + fullMatrix<double> _f0; + void call(dataCacheMap *m, fullMatrix<double> &val) + { + for(int i = 0; i < val.size1(); i++) + for(int j = 0; j < val.size2(); j++) + val(i, j) = fabs(_f0(i, j)); + } + functionAbs(const function *f0) : function(f0->getNbCol()) + { + setArgument (_f0, f0); + } +}; + +function *functionAbsNew (const function *f0) { + return new functionAbs (f0); +} + + + // functionMean class functionMeanP1 : public function { @@ -741,7 +772,7 @@ void functionC::buildLibraryFromFile(const std::string cfilename, const std::str libfilename.c_str(), cfilename.c_str()); fclose(tmpMake); if(system("make -f _tmpMake")) - Msg::Error("make command failed\n"); + Msg::Fatal("make command failed\n"); UnlinkFile("_tmpMake.cpp"); } diff --git a/Solver/function.h b/Solver/function.h index 84ee4052d4..85b05bae7d 100644 --- a/Solver/function.h +++ b/Solver/function.h @@ -64,6 +64,7 @@ class function { void addFunctionReplace(functionReplace &fr); void setArgument(fullMatrix<double> &v, const function *f, int iMap = 0); + void setArgumentWrapped(fullMatrix<double> &v, const function *f, int expectedNbCol, std::string funcName="a function", int iMap=0); virtual void call(dataCacheMap *m, fullMatrix<double> &res) = 0; virtual void registerInDataCacheMap(dataCacheMap *m, dataCacheDouble *d) {} @@ -307,6 +308,7 @@ function *functionMinusNew (const function *f0, const function *f1); function *functionProdNew (const function *f0, const function *f1); function *functionQuotientNew (const function *f0, const function *f1); function *functionScaleNew (const function *f0, const double s); +function *functionAbsNew (const function *f0); function *functionExtractCompNew (const function *f0, const int iComp); function *functionCatCompNew(std::vector<const function *> fArray); function *functionMeanP1New(const function *f, const function *df); diff --git a/Solver/multiscaleLaplace.cpp b/Solver/multiscaleLaplace.cpp index d3f30e56d6..8fe521621f 100644 --- a/Solver/multiscaleLaplace.cpp +++ b/Solver/multiscaleLaplace.cpp @@ -1225,7 +1225,7 @@ void multiscaleLaplace::cutElems(std::vector<MElement *> &elements) connected_left_right(left, right); if (left.size()== 0 || right.size() == 0) { - printf("KO size left=%d, right=%d not good (zero elems)\n", left.size(), right.size() ); + printf("KO size left=%d, right=%d not good (zero elems)\n", (int) left.size(), (int) right.size() ); exit(1); } -- GitLab