{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
module Data.Manifold.Mesh where
import Data.Manifold.Types.Primitive
import Math.Manifold.Core.PseudoAffine
import Data.Manifold.PseudoAffine
import Data.Simplex.Abstract
import Data.Manifold.Web
import Data.Manifold.Web.Internal
import Data.Manifold.FibreBundle
import GHC.Exts (Constraint)
class SimplexSpanning (MeshDomainSpace メ) => Mesh メ where
type MeshDomainSpace メ :: *
type MeshGridDataConstraint メ y :: Constraint
type MeshGridDataConstraint メ y = ()
asWeb :: MeshGridDataConstraint メ y
=> メ y -> PointsWeb (MeshDomainSpace メ) y
meshSimplicesInWeb :: メ y -> [AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId]
meshSimplices :: MeshGridDataConstraint メ y
=> メ y -> [SimplexF (MeshDomainSpace メ) y]
meshSimplices メ y
mesh
= (AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId
-> SimplexF (MeshDomainSpace メ) y)
-> [AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId]
-> [SimplexF (MeshDomainSpace メ) y]
forall a b. (a -> b) -> [a] -> [b]
map ((WebNodeId -> FibreBundle (MeshDomainSpace メ) y)
-> AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId
-> SimplexF (MeshDomainSpace メ) y
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((WebNodeId -> FibreBundle (MeshDomainSpace メ) y)
-> AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId
-> SimplexF (MeshDomainSpace メ) y)
-> (WebNodeId -> FibreBundle (MeshDomainSpace メ) y)
-> AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId
-> SimplexF (MeshDomainSpace メ) y
forall a b. (a -> b) -> a -> b
$ \WebNodeId
i -> case PointsWeb (MeshDomainSpace メ) (WebLocally (MeshDomainSpace メ) y)
-> WebNodeId
-> Maybe (MeshDomainSpace メ, WebLocally (MeshDomainSpace メ) y)
forall x y. PointsWeb x y -> WebNodeId -> Maybe (x, y)
indexWeb PointsWeb (MeshDomainSpace メ) (WebLocally (MeshDomainSpace メ) y)
web WebNodeId
i of
Just (MeshDomainSpace メ
x,WebLocally (MeshDomainSpace メ) y
info) -> (WebLocally (MeshDomainSpace メ) y
infoWebLocally (MeshDomainSpace メ) y
-> Getting y (WebLocally (MeshDomainSpace メ) y) y -> y
forall s a. s -> Getting a s a -> a
^.Getting y (WebLocally (MeshDomainSpace メ) y) y
forall x y. Lens' (WebLocally x y) y
thisNodeData)y -> MeshDomainSpace メ -> FibreBundle (MeshDomainSpace メ) y
forall f m. f -> m -> FibreBundle m f
:@.MeshDomainSpace メ
x
Maybe (MeshDomainSpace メ, WebLocally (MeshDomainSpace メ) y)
Nothing -> [Char] -> FibreBundle (MeshDomainSpace メ) y
forall a. HasCallStack => [Char] -> a
error ([Char] -> FibreBundle (MeshDomainSpace メ) y)
-> [Char] -> FibreBundle (MeshDomainSpace メ) y
forall a b. (a -> b) -> a -> b
$ [Char]
"Faulty `Mesh` instance: node #"[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++WebNodeId -> [Char]
forall a. Show a => a -> [Char]
show WebNodeId
i
[Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++[Char]
" not in web." )
[AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId]
nodeRefs
where web :: PointsWeb (MeshDomainSpace メ) (WebLocally (MeshDomainSpace メ) y)
web = PointsWeb (MeshDomainSpace メ) y
-> PointsWeb (MeshDomainSpace メ) (WebLocally (MeshDomainSpace メ) y)
forall x y.
WithField ℝ Manifold x =>
PointsWeb x y -> PointsWeb x (WebLocally x y)
webLocalInfo (PointsWeb (MeshDomainSpace メ) y
-> PointsWeb
(MeshDomainSpace メ) (WebLocally (MeshDomainSpace メ) y))
-> PointsWeb (MeshDomainSpace メ) y
-> PointsWeb (MeshDomainSpace メ) (WebLocally (MeshDomainSpace メ) y)
forall a b. (a -> b) -> a -> b
$ メ y -> PointsWeb (MeshDomainSpace メ) y
forall (メ :: * -> *) y.
(Mesh メ, MeshGridDataConstraint メ y) =>
メ y -> PointsWeb (MeshDomainSpace メ) y
asWeb メ y
mesh
nodeRefs :: [AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId]
nodeRefs = メ y -> [AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId]
forall (メ :: * -> *) y.
Mesh メ =>
メ y -> [AbstractSimplex (Needle (MeshDomainSpace メ)) WebNodeId]
meshSimplicesInWeb メ y
mesh
:: (WithField ℝ Manifold y, Connected y, MeshGridDataConstraint メ y)
=> メ y -> MeshDomainSpace メ -> y
class Mesh メ => CoveringMesh メ where
interpolateGrid :: (WithField ℝ Manifold y, Connected y, MeshGridDataConstraint メ y)
=> メ y -> MeshDomainSpace メ -> y
interpolateGrid = メ y -> MeshDomainSpace メ -> y
forall (メ :: * -> *) y.
(Mesh メ, WithField ℝ Manifold y, Connected y,
MeshGridDataConstraint メ y) =>
メ y -> MeshDomainSpace メ -> y
extrapolateGrid