/// <summary> /// Returns thermodynamic pressure as function of inital mass and temperature. /// </summary> /// <param name="InitialMass"></param> /// <param name="Temperature"></param> /// <returns></returns> public double GetMassDeterminedThermodynamicPressure(double InitialMass, SinglePhaseField Temperature) { SinglePhaseField OneOverTemperature = new SinglePhaseField(Temperature.Basis); OneOverTemperature.ProjectPow(1.0, Temperature, -1.0); return(InitialMass / OneOverTemperature.IntegralOver(null)); }
/// <summary> /// Approximation of the signum function of the level set field /// </summary> /// <param name="Output"></param> /// <param name="gridParameter"></param> /// <param name="optionalCellMask"></param> public void ApproximateSignFunction( SinglePhaseField Output, double gridParameter, CellMask optionalCellMask) { SinglePhaseField quot = new SinglePhaseField(m_Basis, "quot"); SinglePhaseField sqrt = new SinglePhaseField(m_Basis, "sqrt"); sqrt.ProjectProduct(1.0, this, this, optionalCellMask); sqrt.AccConstant(gridParameter * gridParameter, optionalCellMask); quot.ProjectPow(1.0, sqrt, 0.5, optionalCellMask); //Output.ProjectQuotient (1.0, this, quot,false); Output.ProjectQuotient(1.0, this, quot, optionalCellMask, false); }
/// <summary> /// In this method, the vector normal to the surface as well as certain derivatives /// of it that we intend to use are set up /// </summary> protected void NormalVec(double deltax) { wx = new SinglePhaseField(m_gradBasis, "wx"); wy = new SinglePhaseField(m_gradBasis, "wy"); if (m_Context.Grid.SpatialDimension == 2) { m_Gradw = new VectorField <SinglePhaseField>(wx, wy); } else if (m_Context.Grid.SpatialDimension == 3) { wz = new SinglePhaseField(m_gradBasis, "wz"); m_Gradw = new VectorField <SinglePhaseField>(wx, wy, wz); } else { throw new NotSupportedException("only spatial dimension 2 and 3 are supported."); } SinglePhaseField absval = new SinglePhaseField(m_gradBasis); m_Gradw[0].Derivative(1.0, m_Field, 0); m_Gradw[1].Derivative(1.0, m_Field, 1); if (m_Context.Grid.SpatialDimension == 3) { m_Gradw[2].Derivative(1.0, m_Field, 2); } /* * Normalization of the gradient vector * Might be better implemented using a * Function */ absval.ProjectAbs(1.0, m_Gradw); m_Gradw[0].ProjectQuotient(1.0, m_Gradw[0], absval, null, false); m_Gradw[1].ProjectQuotient(1.0, m_Gradw[1], absval, null, false); if (m_Context.Grid.SpatialDimension == 3) { m_Gradw[2].ProjectQuotient(1.0, m_Gradw[2], absval, null, false); } SinglePhaseField n1x = new SinglePhaseField(m_derivsBasis, "n1x"); SinglePhaseField n2x = new SinglePhaseField(m_derivsBasis, "n2x"); SinglePhaseField n1y = new SinglePhaseField(m_derivsBasis, "n1y"); SinglePhaseField n2y = new SinglePhaseField(m_derivsBasis, "n2y"); if (m_Context.Grid.SpatialDimension == 3) { SinglePhaseField n3x = new SinglePhaseField(m_derivsBasis, "n3x"); SinglePhaseField n3y = new SinglePhaseField(m_derivsBasis, "n3y"); SinglePhaseField n1z = new SinglePhaseField(m_derivsBasis, "n1z"); SinglePhaseField n2z = new SinglePhaseField(m_derivsBasis, "n2z"); SinglePhaseField n3z = new SinglePhaseField(m_derivsBasis, "n3z"); m_normderivs = new VectorField <SinglePhaseField>(n1x, n2x, n3x, n1y, n2y, n3y, n1z, n2z, n3z); /* Partial derivatives of the normal vector. * These quantities are used in the product rule applied to the surface projection * and to compute the mean curvature */ m_normderivs[0].Derivative(1.0, m_Gradw[0], 0); m_normderivs[1].Derivative(1.0, m_Gradw[1], 0); m_normderivs[2].Derivative(1.0, m_Gradw[2], 0); m_normderivs[3].Derivative(1.0, m_Gradw[0], 1); m_normderivs[4].Derivative(1.0, m_Gradw[1], 1); m_normderivs[5].Derivative(1.0, m_Gradw[2], 1); m_normderivs[6].Derivative(1.0, m_Gradw[0], 2); m_normderivs[7].Derivative(1.0, m_Gradw[1], 2); m_normderivs[8].Derivative(1.0, m_Gradw[2], 2); } else { m_normderivs = new VectorField <SinglePhaseField>(n1x, n2x, n1y, n2y); /* Partial derivatives of the normal vector. * These quantities are used in the product rule applied to the surface projection * and to compute the mean curvature */ m_normderivs[0].Derivative(1.0, m_Gradw[0], 0); m_normderivs[1].Derivative(1.0, m_Gradw[1], 0); m_normderivs[2].Derivative(1.0, m_Gradw[0], 1); m_normderivs[3].Derivative(1.0, m_Gradw[1], 1); } /* * Divergence of the surface normal vector yields the total curvature * which is twice the mean curvature * ATTENTION: here with inverse sign!!!!! */ m_Curvature = new SinglePhaseField(m_derivsBasis); m_Curvature.Acc(1.0, m_normderivs[0]); m_Curvature.Acc(1.0, m_normderivs[4]); if (m_Context.Grid.SpatialDimension == 3) { m_Curvature.Acc(1.0, m_normderivs[8]); } m_sign = new SinglePhaseField(m_Basis, "sign"); SinglePhaseField quot = new SinglePhaseField(m_Basis, "quot"); SinglePhaseField sqrt = new SinglePhaseField(m_Basis, "sqrt"); sqrt.ProjectProduct(1.0, m_Field, m_Field); sqrt.AccConstant(0.01); quot.ProjectPow(1.0, sqrt, deltax * deltax); m_sign.ProjectQuotient(1.0, m_Field, quot); }