[Gmsh] Using gmsh as library by C++, received warning message "Staring subloop x in Line Loop 1 (are you sure about this?)
Guowei He
rteycisy at gmail.com
Thu May 10 16:09:56 CEST 2012
No...
The GEdgeLoop.h
On Thu, May 10, 2012 at 4:09 PM, Guowei He <rteycisy at gmail.com> wrote:
> =.=
>
> Never mind, I've found the GEdge.h
>
>
> On Thu, May 10, 2012 at 3:58 PM, Guowei He <rteycisy at gmail.com> wrote:
>
>> Dear gmsh users and ,
>>
>> When the following C++ code is executed to generate a simple rectangle
>> with a circular hole in it, based on the sample given by
>>
>> Takuya OSHIMA, Ph.D. in http://www.geuz.org/pipermail/gmsh/2011/006803.html
>>
>> , warning message "Staring subloop x in Line Loop 1 (are you sure about
>> this?) is prompted during the command "gmsh test.geo", though the geo graph
>> looks fine, the test.geo generated contains some thing like Line Loop(1) =
>> {1, 2, 3, 4, -6, -5}; where 1 2 3 4 are external boundaries and 5 6 are
>> edges of the circle. However a nicer approach in gmsh scripting is do
>> something like
>>
>> // exterior boundary
>> ll1 = newll; Line Loop(ll1) = { l01, l02, l03, l04 };
>>
>> // interstitial domain
>> s1 = news; Plane Surface(s1) = { ll1, beadSurfLoops[] };
>>
>> Is there some corresponding "Loops" object in gmsh library or we only use
>> something like "typedef std::vector<GEdge *> Lineloop;
>> typedef std::vector<Lineloop> Loops;"?
>>
>> Many thanks!
>>
>> ///////////////////////////////////////////////////////////////////
>> test.geo
>> ////////////////////////////////////////////////////////////////////////////////
>> cl1 = 0.08;
>> Point(1) = {9.9, 8, 0, cl1};
>> Point(2) = {-9.9, 8, 0, cl1};
>> Point(3) = {-9.9, -8, 0, cl1};
>> Point(4) = {9.9, -8, 0, cl1};
>> Point(5) = {5, 5, 0, cl1};
>> Point(6) = {5, 7.5, 0, cl1};
>> Point(7) = {5, 2.5, 0, cl1};
>> Line(1) = {1, 2};
>> Line(2) = {2, 3};
>> Line(3) = {3, 4};
>> Line(4) = {4, 1};
>> Circle(5) = {6, 5, 7};
>> Circle(6) = {7, 5, 6};
>> Line Loop(1) = {1, 2, 3, 4, -6, -5};
>> Plane Surface(1) = {1};
>> Line Loop(2) = {5, 6};
>> Plane Surface(2) = {2};
>> Physical Line("inlet") = {1};
>> Physical Line("outlet") = {3};
>> Physical Line("wall") = {2, 4};
>> Physical Surface("interstitial") = {1};
>> Physical Surface("beadface") = {2};
>>
>>
>>
>> ////////////////////////////////////////////////////////// rec.cpp
>> //////////////////////////////////////////////////////////////////////////////////
>> // A simple Gmsh API demonstration program.
>> #include "Gmsh.h"
>> #include "GModel.h"
>> #include "MElement.h"
>> #include "MVertex.h"
>> #include <iostream>
>>
>> typedef std::vector<GEdge *> Lineloop;
>> typedef std::vector<Lineloop> Loops;
>>
>> void *addBead(GModel *m, Loops &l, double const &cx, double const &cy,
>> double const &radius, double const &lc_bead) {
>> Lineloop b;
>> GVertex *gvc1c = m->addVertex(cx, cy, 0, lc_bead);
>> GVertex *gvc1s = m->addVertex(cx, cy - radius, 0, lc_bead);
>> GVertex *gvc1e = m->addVertex(cx, cy + radius, 0, lc_bead);
>> GEdge *gec11 = m->addCircleArcCenter(gvc1s, gvc1c, gvc1e);
>> GEdge *gec12 = m->addCircleArcCenter(gvc1e, gvc1c, gvc1s);
>>
>> b.push_back(gec11);
>> b.push_back(gec12);
>> l.push_back(b);
>> }
>>
>> int main(int argc, char **argv)
>> {
>> // Initialization.
>> GmshInitialize(argc, argv);
>> // Options may be set this way.
>> // Output information messages generated by the Gmsh library.
>> GmshSetOption("General", "Terminal", 1.);
>> // Be verbose (output debug messages).
>> GmshSetOption("General", "Verbosity", 99.);
>> // Create GModel (the Gmsh library core) instance.
>> GModel *m = new GModel;
>> // Choices are "Gmsh" and "OCC" if the Gmsh library is compiled with
>> // OpenCASCADE. Usually you want to use the "Gmsh" factory.
>> m->setFactory("Gmsh");
>>
>> // Add vertices. Equivalent .geo directives are
>> // cl1 = 0.1;
>> // Point(1) = {-1, -1, 0, cl1};
>> // Point(2) = {1, -1, 0, cl1};
>> // Point(3) = {1, 1, 0, cl1};
>> // Point(4) = {-1, 1, 0, cl1};
>> // Point(5) = {0, 0, 0, cl1};
>> const double lc_wall = 0.08, lc_bead = 0.08;
>>
>> // generating walls
>> const double xmin = 10, xmax = -10, ymin = 10, ymax = -10, dx = 0.1, dy
>> = 2;
>>
>> // corner points of rect domain
>> GVertex *gv1 = m->addVertex(xmin - dx, ymin - dy, 0, lc_wall);
>> GVertex *gv2 = m->addVertex(xmax + dx, ymin - dy, 0, lc_wall);
>> GVertex *gv3 = m->addVertex(xmax + dx, ymax + dy, 0, lc_wall);
>> GVertex *gv4 = m->addVertex(xmin - dx, ymax + dy, 0, lc_wall);
>>
>> // lines around the rect domain
>> GEdge *ge1 = m->addLine(gv1, gv2);
>> GEdge *ge2 = m->addLine(gv2, gv3);
>> GEdge *ge3 = m->addLine(gv3, gv4);
>> GEdge *ge4 = m->addLine(gv4, gv1);
>>
>> // // draw circle
>>
>> Loops ls;
>>
>> // exterior boundary
>> Lineloop tmp;
>>
>> tmp.push_back(ge1);
>> tmp.push_back(ge2);
>> tmp.push_back(ge3);
>> tmp.push_back(ge4);
>> ls.push_back(tmp);
>>
>> // call the bead func
>> int nBeads = 1;
>> double radius = ymax / nBeads / 4;
>> double cx = xmin / 2, cy = ymin / 2;
>> for (int i = 0; i < nBeads; i++) {
>> addBead(m, ls, cx, cy, radius, lc_bead);
>> cx += 3 * radius;
>> }
>>
>>
>> // interstitial domain
>> GFace *gf1 = m->addPlanarFace(ls);
>>
>> // create faces of beads
>> Loops::iterator it = ls.begin();
>> it++;
>> std::vector<GRegion *> fbeads;
>> Loops lst;
>> int pn_beadface = m->setPhysicalName(nf_bead, dim_face);
>> for (;it != ls.end(); it++) {
>> lst.push_back(*it);
>> GFace *gft = m->addPlanarFace(lst);
>> gft->addPhysicalEntity(pn_beadface);
>> lst.pop_back();
>> }
>>
>> // The geometry constructed by the operations above may be saved this
>> way.
>> m->writeGEO("test.geo");
>>
>> // Create surface (2-D) mesh. Pass 3 to mesh() if creating a volume
>> // (3-D) mesh.
>> m->mesh(2);
>>
>> // // The created mesh may be saved this way.
>> m->writeMSH("test.msh");
>>
>>
>>
>> // Finalization.
>> delete m;
>> GmshFinalize();
>> }
>>
>>
>> --
>> Kind regards,
>> Guowei He
>>
>>
>
>
> --
> Kind regards,
> Guowei He
>
>
--
Kind regards,
Guowei He
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20120510/275edf01/attachment.html>