mainteam7test.html

来自「有限元学习研究用源代码(老外的),供科研人员参考」· HTML 代码 · 共 106 行

HTML
106
字号
<TITLE>COG 2.0: TEAM example 7</TITLE>

<H1>TEAM example nr.7</H1>

 <P>This is a grid to describe the geometry of the TEAM (Testing
Electromagnetic Analysis Methods) Workshops nr. 7.  It contains an
aluminium plate with a rectangular hole and a coil over the plate:

 <P><IMG SRC="team7test.gif">

<PRE>
#include &lt;math.h&gt;
#include "<A HREF="coglib.hxx">cog/coglib.hxx</A>"
</PRE>
 <P>First, we introduce self-commenting names for regions, faces and
the distances we need:

<PRE>
wzRegion rAir  = 1;
wzRegion rAlu  = 2;
wzRegion rCoil = 3;
wzRegion rHole = 4;

wzFloat lAlu  = 294, hAlu  =  19;	// sizes of the aluminium plate
wzFloat bHole =  18, eHole = 126;	// sizes of the hole in the plate
wzFloat lCoil = 200, dCoil =  25;	// sizes of the coil
wzFloat bCoil = hAlu  +  30;	// minimal z-value of the coil
wzFloat eCoil = bCoil + 100;	// maximal z-value of the coil
wzFloat radius = 50;	// radius of the rounded part of the coil
wzFloat envAlu = 15;	// environment of the aluminium plate discretized
wzFloat uAlu = lAlu+envAlu;	// upper limit for aluminium grid

int main()
{
</PRE>
 <P>This defines the aluminium plate:
<PRE>
  cogenOctree alu = new CogenOctree();
  alu-&gt;addBox(rAlu,  0.0,lAlu,    0.0,lAlu,    0.0,hAlu);
  alu-&gt;addBox(rHole, bHole,eHole,	bHole,eHole, 0.0,hAlu);
  alu-&gt;setBorder(-envAlu,uAlu,-envAlu,uAlu,-envAlu,hAlu+envAlu);
  alu-&gt;refinementGlobal(20,20,10);

</PRE>
 <P>For the coil we use two systems of coordinates: rectangular
coordinates inside (<B>coilinside</B>) and a "rounded box" (a
combination of rectangular coordinates and polar coordinates near the
corners) for the coil itself and the domain outside (<B>coilbase,
coil</B>).

<PRE>
  wzFloat yCoil=lCoil/2,xCoil=lAlu-yCoil,mCoil=yCoil-radius;
  wzRoundedBoxCoordinates&amp; cc = * new 
	wzRoundedBoxCoordinates(xCoil,yCoil,mCoil,mCoil);
  wzcoordinates c3 = new wz3DContinuation(&amp;cc);
  cogenOctree coilbase = new CogenOctree();
  coilbase-&gt;addBox(rCoil, radius-dCoil,radius, 
	cc.ymin[1],cc.ymax[1], bCoil,eCoil);
  coilbase-&gt;setBorder(0,2*radius, cc.ymin[1],cc.ymax[1],-50,eCoil+100);
  coilbase-&gt;refinementGlobal(20,40,50);

  cogenOctree coilinside = new CogenOctree();
  coilinside-&gt;setBorder(xCoil-mCoil,xCoil+mCoil, 
	yCoil-mCoil,yCoil+mCoil, bCoil,eCoil);
  coilinside-&gt;refinementGlobal(40,40,50);
</PRE>

 <P>To add some planes which are part of the other grid increases grid
quality in the intermediate region:

<PRE>
  coilbase-&gt;addPlaneZ(bCoil-10);
  coilbase-&gt;addPlaneZ(hAlu);
  coilbase-&gt;addPlaneZ(hAlu+envAlu);
  coilbase-&gt;addPlaneZ(0.0);
  coilbase-&gt;addPlaneZ(-envAlu);
  coilinside-&gt;addPlaneZ(bCoil-10);
  coilinside-&gt;addPlaneZ(hAlu);
  coilinside-&gt;addPlaneZ(hAlu+envAlu);
  coilinside-&gt;addPlaneZ(0.0);
  coilinside-&gt;addPlaneZ(-envAlu);

  cogenChart coil = new CogenChart(coilbase-&gt;generator(),c3);

  cogenComposite gen = new CogenUnion;
  gen-&gt;add(alu-&gt;generator());
  gen-&gt;add(coil-&gt;generator());
  gen-&gt;add(coilinside-&gt;generator());

  wzgrid grid = (*gen)();

</PRE>
 <P>What remains is to define the material numbers - they are useful
in our output function - and to look at the grid:

<PRE>
  rAir.material()  = rAir;
  rAlu.material()  = rAlu;
  rCoil.material() = rCoil;
  rHole.material() = rAir;
  ibgOutput(grid);
  grid->write("test.sg");
}

</PRE>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?