Skip to content
Snippets Groups Projects
Commit 0fc9c05a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

re-add SphericalRaise: it's easier than Warp (it's reversible!) to plot
radiation patterns
parent 94090b82
No related branches found
No related tags found
No related merge requests found
# $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 # 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 \ ...@@ -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 \ ExtrudeParams.h ../Common/SmoothData.h GFace.h GEdgeLoop.h Pair.h \
GRegion.h OCCVertex.h OCCIncludes.h OCCEdge.h OCCFace.h OCCRegion.h \ GRegion.h OCCVertex.h OCCIncludes.h OCCEdge.h OCCFace.h OCCRegion.h \
../Common/Message.h ../Common/Message.h
FEdge.o: FEdge.cpp FEdge.h GEdge.h GEntity.h Range.h SPoint3.h \ FEdge.o: FEdge.cpp ../Common/Message.h FEdge.h GEdge.h GEntity.h Range.h \
SBoundingBox3d.h ../Common/GmshDefines.h GVertex.h MVertex.h GPoint.h \ SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h GVertex.h MVertex.h \
SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \ GPoint.h SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \ MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
ExtrudeParams.h ../Common/SmoothData.h GModel.h GFace.h GEdgeLoop.h \ ExtrudeParams.h ../Common/SmoothData.h GModel.h GFace.h GEdgeLoop.h \
Pair.h GRegion.h FVertex.h Pair.h GRegion.h FVertex.h
FFace.o: FFace.cpp FVertex.h GModel.h GVertex.h GEntity.h Range.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 \ ...@@ -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 \ SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \ MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
ExtrudeParams.h ../Common/SmoothData.h GFace.h GEdgeLoop.h Pair.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 \ projectionFace.o: projectionFace.cpp projectionFace.h GFace.h GPoint.h \
GEntity.h Range.h SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.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 \ GEdgeLoop.h GEdge.h GVertex.h MVertex.h SPoint2.h SVector3.h MElement.h \
......
# $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 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
# #
...@@ -36,7 +36,7 @@ SRC = Plugin.cpp\ ...@@ -36,7 +36,7 @@ SRC = Plugin.cpp\
StreamLines.cpp CutGrid.cpp\ StreamLines.cpp CutGrid.cpp\
Transform.cpp\ Transform.cpp\
Triangulate.cpp\ Triangulate.cpp\
Warp.cpp\ Warp.cpp SphericalRaise.cpp\
Skin.cpp\ Skin.cpp\
Extract.cpp ExtractElements.cpp ExtractEdges.cpp\ Extract.cpp ExtractElements.cpp ExtractEdges.cpp\
MakeSimplex.cpp\ MakeSimplex.cpp\
...@@ -77,10 +77,10 @@ Plugin.o: Plugin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \ ...@@ -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 \ CutSphere.h Skin.h ../DataStr/Tree.h ../DataStr/avl.h Extract.h \
ExtractElements.h ExtractEdges.h HarmonicToTime.h ModulusPhase.h \ ExtractElements.h ExtractEdges.h HarmonicToTime.h ModulusPhase.h \
Integrate.h Gradient.h Curl.h Divergence.h Annotate.h Remove.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 \ MakeSimplex.h Smooth.h Transform.h Triangulate.h Warp.h \
Eigenvalues.h Lambda2.h Evaluate.h ../Common/OctreePost.h \ SphericalRaise.h Eigenvectors.h Eigenvalues.h Lambda2.h Evaluate.h \
../Common/Octree.h ../Common/OctreeInternals.h Probe.h \ ../Common/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \
../Common/Context.h Probe.h ../Common/Context.h
Levelset.o: Levelset.cpp Levelset.h Plugin.h ../Common/Options.h \ Levelset.o: Levelset.cpp Levelset.h Plugin.h ../Common/Options.h \
../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \ ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \
../DataStr/List.h ../Common/VertexArray.h ../Common/SmoothData.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 \ ...@@ -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/VertexArray.h ../Common/SmoothData.h ../Numeric/Numeric.h \
../Common/AdaptiveViews.h ../Common/GmshMatrix.h Warp.h \ ../Common/AdaptiveViews.h ../Common/GmshMatrix.h Warp.h \
../Common/Context.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 \ Skin.o: Skin.cpp Plugin.h ../Common/Options.h ../Common/Message.h \
../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \ ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \
../Common/VertexArray.h ../Common/SmoothData.h ../Numeric/Numeric.h \ ../Common/VertexArray.h ../Common/SmoothData.h ../Numeric/Numeric.h \
......
// $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 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "Transform.h" #include "Transform.h"
#include "Triangulate.h" #include "Triangulate.h"
#include "Warp.h" #include "Warp.h"
#include "SphericalRaise.h"
#include "Eigenvectors.h" #include "Eigenvectors.h"
#include "Eigenvalues.h" #include "Eigenvalues.h"
#include "Lambda2.h" #include "Lambda2.h"
...@@ -197,6 +198,8 @@ void GMSH_PluginManager::registerDefaultPlugins() ...@@ -197,6 +198,8 @@ void GMSH_PluginManager::registerDefaultPlugins()
("Transform", GMSH_RegisterTransformPlugin())); ("Transform", GMSH_RegisterTransformPlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * > allPlugins.insert(std::pair < char *, GMSH_Plugin * >
("Warp", GMSH_RegisterWarpPlugin())); ("Warp", GMSH_RegisterWarpPlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * >
("SphericalRaise", GMSH_RegisterSphericalRaisePlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * > allPlugins.insert(std::pair < char *, GMSH_Plugin * >
("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin())); ("HarmonicToTime", GMSH_RegisterHarmonicToTimePlugin()));
allPlugins.insert(std::pair < char *, GMSH_Plugin * > allPlugins.insert(std::pair < char *, GMSH_Plugin * >
......
// $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;
}
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment