diff --git a/Geo/Makefile b/Geo/Makefile index d818f5efe870a560bc08a140cefe4bc4348bacf1..269b4c6743844c36c2e5b49d49e11173af825bda 100644 --- a/Geo/Makefile +++ b/Geo/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.144 2007-05-03 08:50:01 geuzaine Exp $ +# $Id: Makefile,v 1.145 2007-05-05 10:24:53 geuzaine Exp $ # # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle # @@ -161,10 +161,10 @@ OCCRegion.o: OCCRegion.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \ ExtrudeParams.h ../Common/SmoothData.h GFace.h GEdgeLoop.h Pair.h \ GRegion.h OCCVertex.h OCCIncludes.h OCCEdge.h OCCFace.h OCCRegion.h \ ../Common/Message.h -FEdge.o: FEdge.cpp FEdge.h GEdge.h GEntity.h Range.h SPoint3.h \ - SBoundingBox3d.h ../Common/GmshDefines.h GVertex.h MVertex.h GPoint.h \ - SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \ - ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \ +FEdge.o: FEdge.cpp ../Common/Message.h FEdge.h GEdge.h GEntity.h Range.h \ + SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h GVertex.h MVertex.h \ + GPoint.h SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \ + MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \ ExtrudeParams.h ../Common/SmoothData.h GModel.h GFace.h GEdgeLoop.h \ Pair.h GRegion.h FVertex.h FFace.o: FFace.cpp FVertex.h GModel.h GVertex.h GEntity.h Range.h \ @@ -172,7 +172,7 @@ FFace.o: FFace.cpp FVertex.h GModel.h GVertex.h GEntity.h Range.h \ SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \ MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \ ExtrudeParams.h ../Common/SmoothData.h GFace.h GEdgeLoop.h Pair.h \ - GRegion.h FFace.h FEdge.h + GRegion.h FFace.h FEdge.h ../Common/Message.h projectionFace.o: projectionFace.cpp projectionFace.h GFace.h GPoint.h \ GEntity.h Range.h SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h \ GEdgeLoop.h GEdge.h GVertex.h MVertex.h SPoint2.h SVector3.h MElement.h \ diff --git a/Plugin/Makefile b/Plugin/Makefile index 8175d70530a629e030f3c0f651c277768c69a734..24555e4f1f9c817463f5a19b5251f088418e02cb 100644 --- a/Plugin/Makefile +++ b/Plugin/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.122 2007-05-04 14:27:41 geuzaine Exp $ +# $Id: Makefile,v 1.123 2007-05-05 10:24:53 geuzaine Exp $ # # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle # @@ -36,7 +36,7 @@ SRC = Plugin.cpp\ StreamLines.cpp CutGrid.cpp\ Transform.cpp\ Triangulate.cpp\ - Warp.cpp\ + Warp.cpp SphericalRaise.cpp\ Skin.cpp\ Extract.cpp ExtractElements.cpp ExtractEdges.cpp\ MakeSimplex.cpp\ @@ -77,10 +77,10 @@ Plugin.o: Plugin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ CutSphere.h Skin.h ../DataStr/Tree.h ../DataStr/avl.h Extract.h \ ExtractElements.h ExtractEdges.h HarmonicToTime.h ModulusPhase.h \ Integrate.h Gradient.h Curl.h Divergence.h Annotate.h Remove.h \ - MakeSimplex.h Smooth.h Transform.h Triangulate.h Warp.h Eigenvectors.h \ - Eigenvalues.h Lambda2.h Evaluate.h ../Common/OctreePost.h \ - ../Common/Octree.h ../Common/OctreeInternals.h Probe.h \ - ../Common/Context.h + MakeSimplex.h Smooth.h Transform.h Triangulate.h Warp.h \ + SphericalRaise.h Eigenvectors.h Eigenvalues.h Lambda2.h Evaluate.h \ + ../Common/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \ + Probe.h ../Common/Context.h Levelset.o: Levelset.cpp Levelset.h Plugin.h ../Common/Options.h \ ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \ ../DataStr/List.h ../Common/VertexArray.h ../Common/SmoothData.h \ @@ -176,6 +176,11 @@ Warp.o: Warp.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/VertexArray.h ../Common/SmoothData.h ../Numeric/Numeric.h \ ../Common/AdaptiveViews.h ../Common/GmshMatrix.h Warp.h \ ../Common/Context.h +SphericalRaise.o: SphericalRaise.cpp Plugin.h ../Common/Options.h \ + ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \ + ../DataStr/List.h ../Common/VertexArray.h ../Common/SmoothData.h \ + ../Numeric/Numeric.h ../Common/AdaptiveViews.h ../Common/GmshMatrix.h \ + SphericalRaise.h ../Common/Context.h Skin.o: Skin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ ../Common/VertexArray.h ../Common/SmoothData.h ../Numeric/Numeric.h \ diff --git a/Plugin/Plugin.cpp b/Plugin/Plugin.cpp index 2e075bc44e4ddaa0f6757a875291e695700233f2..9f2d2e7ba6814e269a8b58defee9df2f6200c74f 100644 --- a/Plugin/Plugin.cpp +++ b/Plugin/Plugin.cpp @@ -1,4 +1,4 @@ -// $Id: Plugin.cpp,v 1.87 2007-05-04 14:27:41 geuzaine Exp $ +// $Id: Plugin.cpp,v 1.88 2007-05-05 10:24:53 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -55,6 +55,7 @@ #include "Transform.h" #include "Triangulate.h" #include "Warp.h" +#include "SphericalRaise.h" #include "Eigenvectors.h" #include "Eigenvalues.h" #include "Lambda2.h" @@ -197,6 +198,8 @@ void GMSH_PluginManager::registerDefaultPlugins() ("Transform", GMSH_RegisterTransformPlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > ("Warp", GMSH_RegisterWarpPlugin())); + allPlugins.insert(std::pair < char *, GMSH_Plugin * > + ("SphericalRaise", GMSH_RegisterSphericalRaisePlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > ("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin())); allPlugins.insert(std::pair < char *, GMSH_Plugin * > diff --git a/Plugin/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp new file mode 100644 index 0000000000000000000000000000000000000000..add290864e2dedc68f9af8fda5b27ff273da444c --- /dev/null +++ b/Plugin/SphericalRaise.cpp @@ -0,0 +1,192 @@ +// $Id: SphericalRaise.cpp,v 1.25 2007-05-05 10:24:53 geuzaine Exp $ +// +// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to <gmsh@geuz.org>. + +#include "Plugin.h" +#include "SphericalRaise.h" +#include "List.h" +#include "Views.h" +#include "Context.h" +#include "Numeric.h" + +extern Context_T CTX; + +StringXNumber SphericalRaiseOptions_Number[] = { + {GMSH_FULLRC, "Xc", NULL, 0.}, + {GMSH_FULLRC, "Yc", NULL, 0.}, + {GMSH_FULLRC, "Zc", NULL, 0.}, + {GMSH_FULLRC, "Raise", NULL, 1.}, + {GMSH_FULLRC, "Offset", NULL, 0.}, + {GMSH_FULLRC, "TimeStep", NULL, 0.}, + {GMSH_FULLRC, "iView", NULL, -1.} +}; + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterSphericalRaisePlugin() + { + return new GMSH_SphericalRaisePlugin(); + } +} + + +GMSH_SphericalRaisePlugin::GMSH_SphericalRaisePlugin() +{ + ; +} + +void GMSH_SphericalRaisePlugin::getName(char *name) const +{ + strcpy(name, "Spherical Raise"); +} + +void GMSH_SphericalRaisePlugin::getInfos(char *author, char *copyright, + char *help_text) const +{ + strcpy(author, "C. Geuzaine"); + strcpy(copyright, "DGR (www.multiphysics.com)"); + strcpy(help_text, + "Plugin(SphericalRaise) transforms the\n" + "coordinates of the elements in the view\n" + "`iView' using the values associated with the\n" + "`TimeStep'-th time step. Instead of elevating\n" + "the nodes along the X, Y and Z axes as in\n" + "View[`iView'].RaiseX, View[`iView'].RaiseY\n" + "and View[`iView'].RaiseZ, the raise is applied\n" + " along the radius of a sphere centered at\n" + "(`Xc', `Yc', `Zc'). To produce a standard\n" + "radiation pattern, set `Offset' to minus the\n" + "radius of the sphere the original data lives on.\n" + "If `iView' < 0, the plugin is run on the current\n" + "view.\n" + "\n" + "Plugin(SphericalRaise) is executed in-place.\n"); +} + +int GMSH_SphericalRaisePlugin::getNbOptions() const +{ + return sizeof(SphericalRaiseOptions_Number) / sizeof(StringXNumber); +} + +StringXNumber *GMSH_SphericalRaisePlugin::getOption(int iopt) +{ + return &SphericalRaiseOptions_Number[iopt]; +} + +void GMSH_SphericalRaisePlugin::catchErrorMessage(char *errorMessage) const +{ + strcpy(errorMessage, "SphericalRaise failed..."); +} + +static void sphericalRaiseList(Post_View * v, List_T * list, int nbElm, + int nbNod, int timeStep, double center[3], + double raise, double offset) +{ + double *x, *y, *z, *val, d[3], coef; + int nb, i, j; + + if(!nbElm) + return; + + if(timeStep > v->NbTimeStep - 1){ + Msg(GERROR, "Invalid TimeStep (%d) in View[%d]", timeStep, v->Index); + return; + } + + v->Changed = 1; + + // for each element + // for each node + // compute d=(x-Xc,y-Yc,z-Zc) + // norm d + // get nodal value val at xyz + // compute (x,y,z)_new = (x,y,z)_old + raise*val*(dx,dy,dz) + + nb = List_Nbr(list) / nbElm; + for(i = 0; i < List_Nbr(list); i += nb) { + x = (double *)List_Pointer_Fast(list, i); + y = (double *)List_Pointer_Fast(list, i + nbNod); + z = (double *)List_Pointer_Fast(list, i + 2 * nbNod); + val = (double *)List_Pointer_Fast(list, i + 3 * nbNod); + for(j = 0; j < nbNod; j++) { + d[0] = x[j] - center[0]; + d[1] = y[j] - center[1]; + d[2] = z[j] - center[2]; + norme(d); + if(timeStep < 0) + coef = raise + offset; + else + coef = raise * val[nbNod * timeStep + j] + offset; + x[j] += coef * d[0]; + y[j] += coef * d[1]; + z[j] += coef * d[2]; + if(x[j] < v->BBox[0]) v->BBox[0] = x[j]; + if(x[j] > v->BBox[1]) v->BBox[1] = x[j]; + if(y[j] < v->BBox[2]) v->BBox[2] = y[j]; + if(y[j] > v->BBox[3]) v->BBox[3] = y[j]; + if(z[j] < v->BBox[4]) v->BBox[4] = z[j]; + if(z[j] > v->BBox[5]) v->BBox[5] = z[j]; + } + } +} + +static void sphericalRaise(Post_View * v, int timeStep, double center[3], + double raise, double offset) +{ + for(int i = 0; i < 3; i++) { + v->BBox[2 * i] = VAL_INF; + v->BBox[2 * i + 1] = -VAL_INF; + } + sphericalRaiseList(v, v->SP, v->NbSP, 1, timeStep, center, raise, offset); + sphericalRaiseList(v, v->SL, v->NbSL, 2, timeStep, center, raise, offset); + sphericalRaiseList(v, v->ST, v->NbST, 3, timeStep, center, raise, offset); + sphericalRaiseList(v, v->SQ, v->NbSQ, 4, timeStep, center, raise, offset); + sphericalRaiseList(v, v->SS, v->NbSS, 4, timeStep, center, raise, offset); + sphericalRaiseList(v, v->SH, v->NbSH, 8, timeStep, center, raise, offset); + sphericalRaiseList(v, v->SI, v->NbSI, 6, timeStep, center, raise, offset); + sphericalRaiseList(v, v->SY, v->NbSY, 5, timeStep, center, raise, offset); +} + +Post_View *GMSH_SphericalRaisePlugin::execute(Post_View * v) +{ + double center[3]; + + center[0] = SphericalRaiseOptions_Number[0].def; + center[1] = SphericalRaiseOptions_Number[1].def; + center[2] = SphericalRaiseOptions_Number[2].def; + double raise = SphericalRaiseOptions_Number[3].def; + double offset = SphericalRaiseOptions_Number[4].def; + int timeStep = (int)SphericalRaiseOptions_Number[5].def; + int iView = (int)SphericalRaiseOptions_Number[6].def; + + if(iView < 0) + iView = v ? v->Index : 0; + + if(!List_Pointer_Test(CTX.post.list, iView)) { + Msg(GERROR, "View[%d] does not exist", iView); + return v; + } + + Post_View *v1 = *(Post_View **)List_Pointer(CTX.post.list, iView); + + sphericalRaise(v1, timeStep, center, raise, offset); + return v1; +} + diff --git a/Plugin/SphericalRaise.h b/Plugin/SphericalRaise.h new file mode 100644 index 0000000000000000000000000000000000000000..f956126ca8456c497ba8490b65921653555bbc9a --- /dev/null +++ b/Plugin/SphericalRaise.h @@ -0,0 +1,42 @@ +#ifndef _SPHERICAL_RAISE_H_ +#define _SPHERICAL_RAISE_H_ + +// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to <gmsh@geuz.org>. + +#include "Plugin.h" + +extern "C" +{ + GMSH_Plugin *GMSH_RegisterSphericalRaisePlugin(); +} + +class GMSH_SphericalRaisePlugin : public GMSH_Post_Plugin +{ +public: + GMSH_SphericalRaisePlugin(); + void getName(char *name) const; + void getInfos(char *author, char *copyright, char *helpText) const; + void catchErrorMessage(char *errorMessage) const; + int getNbOptions() const; + StringXNumber* getOption(int iopt); + Post_View *execute(Post_View *); +}; + +#endif