void CalculateDerivative() { DuDx.Clear(); DuDy.Clear(); DvDx.Clear(); DvDy.Clear(); DuDx.Derivative(1.0, m_app.WorkingSet.Velocity.Current[0], 0); DuDy.Derivative(1.0, m_app.WorkingSet.Velocity.Current[0], 1); DvDx.Derivative(1.0, m_app.WorkingSet.Velocity.Current[1], 0); DvDy.Derivative(1.0, m_app.WorkingSet.Velocity.Current[1], 1); if (m_app.GridData.SpatialDimension == 3) { DuDz.Clear(); DvDz.Clear(); DwDx.Clear(); DwDy.Clear(); DwDz.Clear(); DuDz.Derivative(1.0, m_app.WorkingSet.Velocity.Current[0], 2); DvDz.Derivative(1.0, m_app.WorkingSet.Velocity.Current[1], 2); DwDx.Derivative(1.0, m_app.WorkingSet.Velocity.Current[2], 0); DwDy.Derivative(1.0, m_app.WorkingSet.Velocity.Current[2], 1); DwDz.Derivative(1.0, m_app.WorkingSet.Velocity.Current[2], 2); } }
/// <summary> /// Approximate H1 distance (difference in the H1 norm) between two DG fields; this also supports DG fields on different meshes, /// it could be used for convergence studies. /// </summary> /// <param name="A"></param> /// <param name="B"></param> /// <param name="scheme"> /// a cell quadrature scheme on the coarse of the two meshes /// </param> /// <returns></returns> static public double H1Distance(this ConventionalDGField A, ConventionalDGField B, CellQuadratureScheme scheme = null) { if (A.GridDat.SpatialDimension != B.GridDat.SpatialDimension) { throw new ArgumentException("Both fields must have the same spatial dimension."); } int D = A.GridDat.SpatialDimension; double Acc = 0.0; Acc += L2Distance(A, B, false, scheme).Pow2(); for (int d = 0; d < D; d++) { ConventionalDGField dA_dd = new SinglePhaseField(A.Basis); dA_dd.Derivative(1.0, A, d, scheme != null ? scheme.Domain : null); ConventionalDGField dB_dd = new SinglePhaseField(B.Basis); dB_dd.Derivative(1.0, B, d, scheme != null ? scheme.Domain : null); Acc += L2Distance(dA_dd, dB_dd, false, scheme).Pow2(); } return(Acc.Sqrt()); }
/// <summary> /// see <see cref="DGField.Laplacian(double,DGField,CellMask)"/>; /// </summary> public override void Laplacian(double alpha, DGField f, CellMask em) { SinglePhaseField tmp = new SinglePhaseField(this.Basis, "tmp"); int D = this.GridDat.SpatialDimension; for (int d = 0; d < D; d++) { tmp.Clear(); tmp.Derivative(1.0, f, d, em); this.Derivative(alpha, tmp, d, em); } }
/// <summary> /// This method is meant for the extension of quantities. /// In that equation \Nabla \Phi(x)*sign(\Phi(x)) is needed. /// </summary> protected void SignedNormal() { SinglePhaseField signedwx = new SinglePhaseField(m_gradBasis, "signedwx"); SinglePhaseField signedwy = new SinglePhaseField(m_gradBasis, "signedwy"); dsignedwxd1 = new SinglePhaseField(m_derivsBasis, "dsignedwxd1"); dsignedwyd2 = new SinglePhaseField(m_derivsBasis, "dsignedwyd2"); signedwx.ProjectProduct(1.0, m_sign, m_Gradw[0]); signedwy.ProjectProduct(1.0, m_sign, m_Gradw[1]); dsignedwxd1.Derivative(1.0, signedwx, 0); dsignedwyd2.Derivative(1.0, signedwy, 1); if (m_Context.Grid.SpatialDimension == 3) { SinglePhaseField signedwz = new SinglePhaseField(m_gradBasis, "signedwz"); dsignedwzd3 = new SinglePhaseField(m_derivsBasis, "dsignedwzd3"); signedwz.ProjectProduct(1.0, m_sign, m_Gradw[2]); dsignedwzd3.Derivative(1.0, signedwz, 2); } }