cogregiontest.html

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

HTML
61
字号
<TITLE>COG 1.0 - CogeometrySimpleRegions</TITLE>

<H2>class <A NAME="Regions">CogeometrySimpleRegions</A></H2>

<PRE>
#include "cogfunction.hxx"
</PRE>

 <P>Here we want to introduce a possibility to define cogeometries
which is very variable - it allows to use the full power of C++ as an
input language for geometry definition.

 <P>This class allows you to define a cogeometry by any function f(x)
which defines the region containing x.  All what you need is to
understand how to obtain the coordinates of the point (<A
HREF="wzpointtest.html">wzPoint</A>):

<PRE>
#include &lt;math.h&gt;

static cogSegment Regions(const cogPoint& x)
{
 if(sin(10*x[1]) - 1.5*x[2]*x[2] - 1.4*x[0]*x[0]*(x[0]-0.67) &gt; 0) return cogRegion(2);
 if(sin(10*x[2]) - 1.5*x[0]*x[0] - 1.4*x[1]*x[1]*(x[1]-0.67) &gt; 0) return cogRegion(3);
 if(x[0]+0.1*x[1]+0.2*x[2] &gt; 1.0) return cogRegion(4);
 if(x[0]+0.1*x[1]+0.2*x[2] &gt; 0.8) return cogRegion(5);
 if(x[0]+0.1*x[1]+0.2*x[2] &gt; 0.6) return cogRegion(6);
 return cogRegion(7);
}
</PRE>

 <P>Don't bother that the return type is <B>cogSegment</B>. You have
to return a <B>cogRegion</B>, there is an automatical conversion to
<B>cogSegment</B>.  (The technical reason is that the same function
type will be used elsewhere.)

<PRE>
cogeometry	test_cogeometry()
{
  return new CogeometrySimpleRegions(<A HREF="#Regions">Regions</A>);
}
</PRE>

 <P>A similar method may be used to define 
 <A HREF="cogfacetest.html">boundary conditions</A>.

<H2>Modification for Local Parameter Dependence</H2>

 <P>Of course, global parameters are not a problem. But you may want
to define a general scheme of a cogeometry by a parameter-dependent
function, and to define a cogeometry which depends on these parameters
locally, in the sense that a change of these parameters for on
geometry does not change the parameters for another. A function
depending on global parameters doesn't help. In this case, I recommend
to define an own class. Name it
<B>Cogeometry<I>WhateverYouWant</I></B>, and simply use the scheme of
definition of the class <B>CogeometrySimpleRegions</B> which is
defined in <A HREF="cogfunction.hxx">cogfunction.hxx</A>.  Examples
you can find in <A HREF="cogsimple.hxx">cogsimple.hxx</A>, <A
HREF="cogsimple.cxx">cogsimple.cxx</A>.

⌨️ 快捷键说明

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