/* * 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; }
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); } */ 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); }
/* * 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); }
public Face(Vector2 v1, Vector2 v2) { vertex[0] = v1; vertex[1] = v2; isboundary = false; bnddomain = -1; bndgroup = -1; }
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()); } } }
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; // от левый нижний против часовой }
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(); }
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 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 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); }
/* 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); }
public Face(Vector2 v1, Vector2 v2) { vertex[0] = v1; vertex[1] = v2; isboundary = false; }
/* * 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); }
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]); }
/* * 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); }
public void SetPolygon(Vector2[] vertexs) { vertex = vertexs; // от левый нижний против часовой }
/* 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; }
/* 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); }
/* 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); }