/// <summary> /// computes a cell mask that contains all cells with an edge in this edge mask /// </summary> public CellMask GetAdjacentCells(Grid.Classic.GridData gridData) { int J = gridData.Cells.NoOfLocalUpdatedCells; int[,] AllEdges = gridData.Edges.CellIndices; BitArray mask = new BitArray(J); foreach (var ch in this) { int L = ch.i0 + ch.Len; for (int l = ch.i0; l < L; l++) { int cellIn = AllEdges[l, 0]; int cellOt = AllEdges[l, 1]; if (cellIn < J) { mask[cellIn] = true; } if (cellOt >= 0 && cellOt < J) { mask[cellOt] = true; } } } return(new CellMask(gridData, mask)); }
/// <summary> /// constructor, for a quadrature rule which is already compiled (<paramref name="domNrule"/>) /// </summary> /// <param name="noOfIntegralsPerCell">tensor dimension of the integrand</param> /// <param name="context"></param> /// <param name="domNrule">quadrature rule and domain</param> /// <param name="cs">Physical or reference coordinate system?</param> public CellBoundaryQuadrature( int[] noOfIntegralsPerCell, Grid.Classic.GridData context, ICompositeQuadRule <TQuadRule> domNrule, CoordinateSystem cs = Quadrature.CoordinateSystem.Physical) : base(noOfIntegralsPerCell, context, domNrule, cs) // { foreach (IChunkRulePair <QuadRule> crp in domNrule) { NodeCoordinateSystem ncs = crp.Rule.Nodes.GetNodeCoordinateSystem(context); if (ncs != NodeCoordinateSystem.CellCoord) { throw new ArgumentException("Illegal node set for cell boundary quadrature. Found some node set defined for: " + ncs.ToString() + "."); } } }
/// <summary> /// creates an edge quadrature, where integrand evaluation (<paramref name="_Evaluate"/>) and other methods /// can be passed as delegates. Use this, if you do not want to derive from <see cref="EdgeQuadrature"/>. /// </summary> static public EdgeQuadrature GetQuadrature(int[] noOfIntegralsPerCell, Grid.Classic.GridData context, ICompositeQuadRule <QuadRule> domNrule, Del_Evaluate _Evaluate, Del_SaveIntegrationResults _SaveIntegrationResults, Del_AllocateBuffers _AllocateBuffers = null, Del_QuadNodesChanged _PostLockNodes = null, CoordinateSystem cs = CoordinateSystem.Physical) { var ret = new EdgeQuadratureImpl(noOfIntegralsPerCell, context, domNrule, cs) { m_Evaluate = _Evaluate, m_SaveIntegrationResults = _SaveIntegrationResults, m_AllocateBuffers = _AllocateBuffers, m_quadNodesChanged = _PostLockNodes, }; return(ret); }
/// <summary> /// a cell is in the returned cell mask if /// it is a neighbor cell of this edge mask and if it is also neighbor of <paramref name="X"/> /// </summary> public CellMask GetAdjacentCellsCond(Grid.Classic.GridData gridData, CellMask X) { int J = gridData.Cells.NoOfLocalUpdatedCells; int[,] AllEdges = gridData.Edges.CellIndices; BitArray mask = new BitArray(J); BitArray Xmask = X.GetBitMaskWithExternal(); foreach (var ch in this) { int L = ch.i0 + ch.Len; for (int l = ch.i0; l < L; l++) { int cellIn = AllEdges[l, 0]; int cellOt = AllEdges[l, 1]; bool Out = (cellOt > 0 && Xmask[cellOt]); bool In_ = Xmask[cellIn]; if (!(Out || In_)) { continue; } if (cellIn < J) { mask[cellIn] = true; } if (cellOt >= 0 && cellOt < J) { mask[cellOt] = true; } } } return(new CellMask(gridData, mask)); }
/// <summary> /// Alternative constructor that allows for the usage of a scheme /// instead of a compiled quadrature rule. /// </summary> /// <param name="noOfIntegralsPerCell"></param> /// <param name="context"></param> /// <param name="scheme"></param> /// <param name="order"></param> /// <param name="cs">integrate in physical or reference coordinates?</param> protected Quadrature( int[] noOfIntegralsPerCell, Grid.Classic.GridData context, IQuadratureScheme <TQuadRule, TDomain> scheme, int order, CoordinateSystem cs) : this(noOfIntegralsPerCell, context, scheme.Compile(context, order), cs) { }
public CellBoundaryQuadratureImpl( int[] noOfIntegralsPerCell, Grid.Classic.GridData context, ICompositeQuadRule <TQuadRule> domNrule, CoordinateSystem cs) : base(noOfIntegralsPerCell, context, domNrule, cs) { }
/// <summary> /// constructor /// </summary> public EdgeRuleFromCellBoundaryFactory(Grid.Classic.GridData g, IQuadRuleFactory <CellBoundaryQuadRule> cellBndQF, CellMask maxDomain) { m_cellBndQF = cellBndQF; grd = g; m_maxDomain = maxDomain; }
/// <summary> /// Saves the location and weight associated with each node in /// <paramref name="compositeRule"/> into a text file /// </summary> public static void ToTextFileVolume(this ICompositeQuadRule <QuadRule> compositeRule, Grid.Classic.GridData gridData, string filename) { int D = gridData.SpatialDimension; string[] dimensions = new string[] { "x", "y", "z" }; using (var file = new StreamWriter(filename)) { file.WriteLine(String.Format( "Cell\t{0}\tWeight", dimensions.Take(D).Aggregate((s, t) => s + "\t" + t))); foreach (IChunkRulePair <QuadRule> pair in compositeRule) { MultidimensionalArray globalNodes = gridData.GlobalNodes.GetValue_Cell(pair.Rule.Nodes, pair.Chunk.i0, pair.Chunk.Len); foreach (var cell in pair.Chunk.Elements.AsSmartEnumerable()) { for (int n = 0; n < pair.Rule.NoOfNodes; n++) { file.Write(cell.Value); for (int d = 0; d < D; d++) { file.Write("\t{0}", globalNodes[cell.Index, n, d].ToString("E", NumberFormatInfo.InvariantInfo)); } file.WriteLine("\t{0}", pair.Rule.Weights[n].ToString("E", NumberFormatInfo.InvariantInfo)); } } file.Flush(); } } }
/// <summary> /// Constructs a new context. /// </summary> public GridInitializationContext(Grid.Classic.GridData gridData) { this.GridData = gridData; }
/// <summary> /// Does nothing. /// </summary> /// <param name="gridData"></param> public void AddGridInitializationContext(Grid.Classic.GridData gridData) { }