mainstarttest.html
来自「有限元学习研究用源代码(老外的),供科研人员参考」· HTML 代码 · 共 76 行
HTML
76 行
<TITLE>COG 2.0: Startup File</TITLE>
<A HREF="mainoctreetest.html">next</A>
<H1>COG 2.0: Startup File</H1>
<P>Let's start with the simplest 3D grid example - a cube,
consisting of six tetrahedra. We need, of course, an include file:
<PRE>
#include "<A HREF="coglib.hxx">cog/coglib.hxx</A>"
int main()
{
</PRE>
<P>We also need a grid generator - an object of the abstract class
<B>Cogenerator</B>. For the first example, we use the grid generator
from the derived class
<B><A HREF="cogenoctree.html">CogenOctree</A></B>. The related pointer
type is <B>cogenOctree</B> (don't use CogenOctree* for a pointer!!!).
<PRE>
cogenOctree gen = new CogenOctree();
</PRE>
<P>Then, we define the bounding box for grid generation:
<PRE>
gen->setBorder(0.0,1.0, 0.0,1.0, 0.0,1.0); // 3D unit cube
// gen->setBorder(0.0,1.0, 0.0,1.0); // 2D unit square
// gen->setBorder(0.0,1.0); // 1D unit segment
</PRE>
<P>That's all we need for our first test example. Now, we can call
the grid generator:
<PRE>
wzgrid grid = (*gen)();
</PRE>
<P>Now we can use the grid, for example, write it into a file:
<PRE>
grid->write("test.sg");
}
</PRE>
<P>The <A HREF="format.html">grid format</A> is very simple.
<H2>How to test the example code</H2>
<P>The example code from tutorial files may be extracted and tested.
For this purpose, I have written some perl scripts. If you have perl,
this allows you not only to test the predefined test examples, but
even to modify them and to extract and test the modified code in the
same way.
<P>All the files with filenames of type "<B>main*test.html</B>"
contain valid test code. This code may be automatically extracted
using the perl scripts <B>run</B> and <B>use</B>.
<P><B>> run main start</B>
<P>tests this example. You can do the same in two steps:
<P><B>> use main start</B>
<BR><B>> run</B>
<P>The command <B>use main xyz</B> extracts the code from
mainxyztest.html into <B>maintest.cxx</B>. The <B>run</B> command
compiles, links and runs the program <B>maintest.cxx</B>.
<P>Now, in our tutorial we continue with
<A HREF="mainoctreetest.html">other possibilities of the class
CogenOctree</A>.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?