Example #1
0
        /*
         * public void CalcFluxes()
         * {
         *  int nf = 0;
         *
         *  Vector2 gradC = CalcGradient();
         *
         *  for (nf = 0; nf < vertex.Length; nf++)
         *  {
         *      Face face = faces[nf];
         *      Element nb = nbs[nf];
         *      if (face.isboundary)
         *      {
         *          if (face.boundaryType == BoundaryType.BND_CONST)
         *          {
         *              double flux1nf;
         *              flux1nf = k * (face.area / nodedistances[nf]);
         *              Vector2 Sf = face.sf.Clone();
         *              Vector2 dCf = cfdistance[nf].Clone();
         *              if (Sf * dCf < 0)
         *                  Sf = -Sf;
         *              //1) minimum correction
         *              //Vector2 DCF = elem.cndistance[nf].Clone();
         *              Vector2 e1 = dCf.GetNormalize();
         *              Vector2 EF = (e1 * Sf) * e1;
         *              flux[nf] = k * (EF.Length() / dCf.Length());
         *
         *          }
         *          else if (face.boundaryType == BoundaryType.BND_INSULATED)
         *          {
         *              flux[nf] = 0;
         *          }
         *      }
         *      else
         *      {
         *          double flux1nf;
         *          flux1nf = -k * (face.area / nodedistances[nf]);
         *          Vector2 Sf = face.sf.Clone();
         *          Vector2 dCf = cfdistance[nf].Clone();
         *          if (Sf * dCf < 0)
         *              Sf = -Sf;
         *          //1) minimum correction
         *          Vector2 DCF = cndistance[nf].Clone();
         *          Vector2 e1 = DCF.GetNormalize();
         *          //corrected flux
         *          Vector2 EF = (e1 * Sf) * e1;
         *
         *          flux[nf] = -k * (EF.Length() / DCF.Length());
         *
         *          Vector2 gradnb = new Vector2();
         *
         *          Vector2 gradface = geomInterpolateFactor[nf] * gradnb + (1 - geomInterpolateFactor[nf]) * gradC;
         *          Vector2 TF = Sf - EF;
         *          double fluxT = -(gradface * TF);
         *
         *          flux[nf] += fluxT;
         *
         *      }
         *
         *  }
         * }
         */

        public void CalcGradient()
        {
//            return;
            int nf = 0;

            gradient = new Vector2();
            for (nf = 0; nf < vertex.Length; nf++)
            {
                if (faces[nf].isboundary)
                {
                    faces[nf].u = faces[nf].bndu;
                }
                else
                {
                    //faces[nf].u = (u + nbs[nf].u) / 2.0;
                    double gInterpolateFactor = cfdistance[nf].Length() / cndistance[nf].Length();
                    faces[nf].u = gInterpolateFactor * nbs[nf].u + (1 - gInterpolateFactor) * u;
                }
                Vector2 Sf  = faces[nf].sf.Clone();
                Vector2 dCf = cfdistance[nf].Clone();
                if (Sf * dCf < 0)
                {
                    Sf = -Sf;
                }
                gradient += faces[nf].u * Sf;
            }
            gradient = gradient / volume;
        }
Example #2
0
 public void SetRectangle(double x1, double y1, double w, double h)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x1 + w, y1);
     vertex[2] = new Vector2(x1 + w, y1 + h);
     vertex[3] = new Vector2(x1, y1 + h);
 }
Example #3
0
 /*
 public void SetTriangle(double x1, double y1,double x2, double y2,double x3, double y3)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x2, y2);
     vertex[2] = new Vector2(x3, y3);
 }
  */
 public void SetPolygon4(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x2, y2);
     vertex[2] = new Vector2(x3, y3);
     vertex[3] = new Vector2(x4, y4);
 }
Example #4
0
 public void SetRectangle(double x1, double y1, double w, double h)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x1 + w, y1);
     vertex[2] = new Vector2(x1 + w, y1 + h);
     vertex[3] = new Vector2(x1, y1 + h);
 }
Example #5
0
 /*
  * public void SetTriangle(double x1, double y1,double x2, double y2,double x3, double y3)
  * {
  *  vertex[0] = new Vector2(x1, y1);
  *  vertex[1] = new Vector2(x2, y2);
  *  vertex[2] = new Vector2(x3, y3);
  * }
  */
 public void SetPolygon4(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x2, y2);
     vertex[2] = new Vector2(x3, y3);
     vertex[3] = new Vector2(x4, y4);
 }
Example #6
0
 public Face(Vector2 v1, Vector2 v2)
 {
     vertex[0]  = v1;
     vertex[1]  = v2;
     isboundary = false;
     bnddomain  = -1;
     bndgroup   = -1;
 }
Example #7
0
 public Face(Vector2 v1, Vector2 v2)
 {
     vertex[0] = v1;
     vertex[1] = v2;
     isboundary = false;
     bnddomain = -1;
     bndgroup = -1;
 }
Example #8
0
        public void CalcFluxes()
        {
            int nf = 0;

            for (nf = 0; nf < vertex.Length; nf++)
            {
                Face    face = faces[nf];
                Element nb   = nbs[nf];
                if (face.isboundary)
                {
                    if (face.boundaryType == BoundaryType.BND_CONST)
                    {
                        double flux1nf;
                        flux1nf = k * (face.area / nodedistances[nf]);
                        Vector2 Sf  = face.sf.Clone();
                        Vector2 dCf = cfdistance[nf].Clone();
                        if (Sf * dCf < 0)
                        {
                            Sf = -Sf;
                        }
                        //1) minimum correction
                        //Vector2 DCF = elem.cndistance[nf].Clone();
                        Vector2 e1 = dCf.GetNormalize();
                        Vector2 EF = (e1 * Sf) * e1;
                        flux[nf] = k * (EF.Length() / dCf.Length());
                    }
                    else if (face.boundaryType == BoundaryType.BND_INSULATED)
                    {
                        flux[nf] = 0;
                    }
                }
                else
                {
                    double flux1nf;
                    flux1nf = -k * (face.area / nodedistances[nf]);
                    Vector2 Sf  = face.sf.Clone();
                    Vector2 dCf = cfdistance[nf].Clone();
                    if (Sf * dCf < 0)
                    {
                        Sf = -Sf;
                    }
                    Vector2 DCF = cndistance[nf].Clone();
                    Vector2 e1  = DCF.GetNormalize();
                    //corrected flux
                    //1) minimum correction
                    Vector2 EF = (e1 * Sf) * e1;

                    flux[nf] = -k * (EF.Length() / DCF.Length());
                }
            }
        }
Example #9
0
        public void SetPolygon(Vector2[] vertexs)
        {
            int vcount = vertexs.Length;

            faces = new Face[vcount];
            nbs = new Element[vcount];
            nodes = new Node[vcount];
            cndistance = new Vector2[vcount];
            nodedistances = new double[vcount];
            cfdistance = new Vector2[vcount];
            nfdistance = new Vector2[vcount];
            geomInterpolateFactor = new double[vcount];
            flux = new double[vcount];
            vertex = vertexs; // от левый нижний против часовой
        }
Example #10
0
 public void Calc()
 {
     area = (vertex[0] - vertex[1]).Length();
     centroid = (vertex[0] + vertex[1]) / 2;
     normal = EMath.Geometry2D.LineNormal(vertex[0], vertex[1]);
     if (nbelem != null)
     {
         faceinterpolcoeff = owner.volume / (owner.volume + nbelem.volume);
         k = (owner.k * nbelem.k) / ((1 - faceinterpolcoeff) * owner.k + faceinterpolcoeff * nbelem.k);
     }
     else
     {
         k = owner.k;
     }
     //        sf = normal * area; //(vertex[0]-vertex[1]).Length();
 }
Example #11
0
 public void Calc()
 {
     area     = (vertex[0] - vertex[1]).Length();
     centroid = (vertex[0] + vertex[1]) / 2;
     normal   = EMath.Geometry2D.LineNormal(vertex[0], vertex[1]);
     if (nbelem != null)
     {
         faceinterpolcoeff = owner.volume / (owner.volume + nbelem.volume);
         k = (owner.k * nbelem.k) / ((1 - faceinterpolcoeff) * owner.k + faceinterpolcoeff * nbelem.k);
     }
     else
     {
         k = owner.k;
     }
     //        sf = normal * area; //(vertex[0]-vertex[1]).Length();
 }
Example #12
0
        public Face FindFaceByVertex(Vector2 v1,Vector2 v2)
        {
            Face f = null;

            for (int n = 0; n < faces.Length; n++)
            {
                Face nf = faces[n];
                if (v1.Equal(nf.vertex[0]) || v2.Equal(nf.vertex[0]))
                {
                    if (v1.Equal(nf.vertex[1]) || v2.Equal(nf.vertex[1]))
                    {
                        f = nf;
                        break;
                    }
                }
            }

            return f;
        }
Example #13
0
        public Face FindFaceByVertex(Vector2 v1, Vector2 v2)
        {
            Face f = null;

            for (int n = 0; n < faces.Length; n++)
            {
                Face nf = faces[n];
                if (v1.Equal(nf.vertex[0]) || v2.Equal(nf.vertex[0]))
                {
                    if (v1.Equal(nf.vertex[1]) || v2.Equal(nf.vertex[1]))
                    {
                        f = nf;
                        break;
                    }
                }
            }

            return(f);
        }
Example #14
0
        /*
         * public void SetTriangle(double x1, double y1,double x2, double y2,double x3, double y3)
         * {
         *  vertex[0] = new Vector2(x1, y1);
         *  vertex[1] = new Vector2(x2, y2);
         *  vertex[2] = new Vector2(x3, y3);
         * }
         */
        public void SetPolygon4(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
        {
            int vcount = 4;

            faces                 = new Face[vcount];
            nbs                   = new Element[vcount];
            vertex                = new Vector2[vcount]; // от левый нижний против часовой
            nodes                 = new Node[vcount];
            cndistance            = new Vector2[vcount];
            nodedistances         = new double[vcount];
            cfdistance            = new Vector2[vcount];
            nfdistance            = new Vector2[vcount];
            geomInterpolateFactor = new double[vcount];
            flux                  = new double[vcount];


            vertex[0] = new Vector2(x1, y1);
            vertex[1] = new Vector2(x2, y2);
            vertex[2] = new Vector2(x3, y3);
            vertex[3] = new Vector2(x4, y4);
        }
Example #15
0
        /*
        public void SetTriangle(double x1, double y1,double x2, double y2,double x3, double y3)
        {
            vertex[0] = new Vector2(x1, y1);
            vertex[1] = new Vector2(x2, y2);
            vertex[2] = new Vector2(x3, y3);
        }
         */
        public void SetPolygon4(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
        {

            int vcount = 4;

            faces = new Face[vcount];
            nbs = new Element[vcount];
            vertex = new Vector2[vcount]; // от левый нижний против часовой
            nodes = new Node[vcount];
            cndistance = new Vector2[vcount];
            nodedistances = new double[vcount];
            cfdistance = new Vector2[vcount];
            nfdistance = new Vector2[vcount];
            geomInterpolateFactor = new double[vcount];
            flux = new double[vcount];


            vertex[0] = new Vector2(x1, y1);
            vertex[1] = new Vector2(x2, y2);
            vertex[2] = new Vector2(x3, y3);
            vertex[3] = new Vector2(x4, y4);
        }
Example #16
0
 public Face(Vector2 v1, Vector2 v2)
 {
     vertex[0]  = v1;
     vertex[1]  = v2;
     isboundary = false;
 }
Example #17
0
 /*
  * public Face FindFaceByVertex(Vector2 v1,Vector2 v2)
  * {
  *  Face f = null;
  *
  *  for (int n = 0; n < faces.Length; n++)
  *  {
  *      Face nf = faces[n];
  *      if (v1.Equal(nf.vertex[0]) || v2.Equal(nf.vertex[0]))
  *      {
  *          if (v1.Equal(nf.vertex[1]) || v2.Equal(nf.vertex[1]))
  *          {
  *              f = nf;
  *              break;
  *          }
  *      }
  *  }
  *
  *  return f;
  * }
  */
 public void PreCalc()
 {
     centroid = EMath.Geometry2D.PolygonCentroid(vertex);
     //volume =EMath.Geometry2D.TriangleArea(vertex[0], vertex[1], vertex[2]);
     volume = EMath.Geometry2D.PolygonArea(vertex);
 }
Example #18
0
 public void PreCalc()
 {
     centroid = EMath.Geometry2D.PolygonCentroid(vertex);
     volume   = (vertex[1].x - vertex[0].x) * (vertex[2].y - vertex[1].y); //poligonarea//EMath.Geometry2D.TriangleArea(vertex[0], vertex[1], vertex[2]);
 }
Example #19
0
 /*
  * public void SetRectangle(double x1, double y1, double w, double h)
  * {
  *  vertex[0] = new Vector2(x1, y1);
  *  vertex[1] = new Vector2(x1 + w, y1);
  *  vertex[2] = new Vector2(x1 + w, y1 + h);
  *  vertex[3] = new Vector2(x1, y1 + h);
  * }
  */
 public void SetTriangle(double x1, double y1, double x2, double y2, double x3, double y3)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x2, y2);
     vertex[2] = new Vector2(x3, y3);
 }
Example #20
0
 public void SetPolygon(Vector2[] vertexs)
 {
     vertex = vertexs; // от левый нижний против часовой
 }
Example #21
0
        /*
        public void CalcFluxes()
        {
            int nf = 0;

            Vector2 gradC = CalcGradient();

            for (nf = 0; nf < vertex.Length; nf++)
            {
                Face face = faces[nf];
                Element nb = nbs[nf];
                if (face.isboundary)
                {
                    if (face.boundaryType == BoundaryType.BND_CONST)
                    {
                        double flux1nf;
                        flux1nf = k * (face.area / nodedistances[nf]);
                        Vector2 Sf = face.sf.Clone();
                        Vector2 dCf = cfdistance[nf].Clone();
                        if (Sf * dCf < 0)
                            Sf = -Sf;
                        //1) minimum correction
                        //Vector2 DCF = elem.cndistance[nf].Clone();
                        Vector2 e1 = dCf.GetNormalize();
                        Vector2 EF = (e1 * Sf) * e1;
                        flux[nf] = k * (EF.Length() / dCf.Length());

                    }
                    else if (face.boundaryType == BoundaryType.BND_INSULATED)
                    {
                        flux[nf] = 0;
                    }
                }
                else
                {
                    double flux1nf;
                    flux1nf = -k * (face.area / nodedistances[nf]);
                    Vector2 Sf = face.sf.Clone();
                    Vector2 dCf = cfdistance[nf].Clone();
                    if (Sf * dCf < 0)
                        Sf = -Sf;
                    //1) minimum correction
                    Vector2 DCF = cndistance[nf].Clone();
                    Vector2 e1 = DCF.GetNormalize();
                    //corrected flux
                    Vector2 EF = (e1 * Sf) * e1;

                    flux[nf] = -k * (EF.Length() / DCF.Length());

                    Vector2 gradnb = new Vector2();

                    Vector2 gradface = geomInterpolateFactor[nf] * gradnb + (1 - geomInterpolateFactor[nf]) * gradC;
                    Vector2 TF = Sf - EF;
                    double fluxT = -(gradface * TF);

                    flux[nf] += fluxT;

                }

            }
        }
        */

        public void CalcGradient()
        {
//            return;
            int nf = 0;
            gradient = new Vector2();
            for (nf = 0; nf < vertex.Length; nf++)
            {
                if (faces[nf].isboundary)
                {
                    faces[nf].u = faces[nf].bndu;
                }
                else
                {
                    //faces[nf].u = (u + nbs[nf].u) / 2.0;
                    double gInterpolateFactor = cfdistance[nf].Length() / cndistance[nf].Length();
                    faces[nf].u = gInterpolateFactor * nbs[nf].u + (1 - gInterpolateFactor) * u;
                }
                Vector2 Sf = faces[nf].sf.Clone();
                Vector2 dCf = cfdistance[nf].Clone();
                if (Sf * dCf < 0)
                    Sf = -Sf;
                gradient+=faces[nf].u * Sf;
            }
            gradient = gradient / volume;

        }
Example #22
0
        /*
        public Face FindFaceByVertex(Vector2 v1,Vector2 v2)
        {
            Face f = null;

            for (int n = 0; n < faces.Length; n++)
            {
                Face nf = faces[n];
                if (v1.Equal(nf.vertex[0]) || v2.Equal(nf.vertex[0]))
                {
                    if (v1.Equal(nf.vertex[1]) || v2.Equal(nf.vertex[1]))
                    {
                        f = nf;
                        break;
                    }
                }
            }

            return f;
        }
         */ 
        public void PreCalc()
        {
            centroid = EMath.Geometry2D.PolygonCentroid(vertex);
            //volume =EMath.Geometry2D.TriangleArea(vertex[0], vertex[1], vertex[2]);
            volume = EMath.Geometry2D.PolygonArea(vertex);
        }
Example #23
0
 public void PreCalc()
 {
     centroid = EMath.Geometry2D.PolygonCentroid(vertex);
     volume = (vertex[1].x - vertex[0].x) * (vertex[2].y - vertex[1].y); //poligonarea//EMath.Geometry2D.TriangleArea(vertex[0], vertex[1], vertex[2]);
 }
Example #24
0
 public Face(Vector2 v1, Vector2 v2)
 {
     vertex[0] = v1;
     vertex[1] = v2;
     isboundary = false;
 }
Example #25
0
 /*
 public void SetRectangle(double x1, double y1, double w, double h)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x1 + w, y1);
     vertex[2] = new Vector2(x1 + w, y1 + h);
     vertex[3] = new Vector2(x1, y1 + h);
 }
  */ 
 public void SetTriangle(double x1, double y1,double x2, double y2,double x3, double y3)
 {
     vertex[0] = new Vector2(x1, y1);
     vertex[1] = new Vector2(x2, y2);
     vertex[2] = new Vector2(x3, y3);
 }