How to use the underworld.function.coord function in underworld

To help you get started, we’ve selected a few underworld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_unitvec_r(self):
        pos = fn.coord()
        mag = fn.math.sqrt(fn.math.dot( pos, pos ))
        r_vec = pos / mag
        return r_vec
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_r_lon_lat(self):
        pos = fn.coord()
        rFn = fn.math.sqrt(pos[0]**2 + pos[1]**2 + pos[2]**2)
        lonFn = fn.math.atan2(pos[2],pos[1])
        latFn = fn.math.asin(pos[0]/rFn)
        return rFn, lonFn, latFn
github underworldcode / underworld2 / docs / development / models_inprogress / uw3 / poisson3D.py View on Github external
from libUnderworld import petsc_layer as pl
from underworld import function as fn
import numpy as np

model = uw.systems.pl_PoissonModel()

# these following 2 fn are made available by the model
temperature  = model.fn_temperature

'''
PI = fn.misc.constant(3.14159265359)
my_k = fn.math.sin( PI * ( fn_r / 5. - 1. ) )
'''

someFn = fn.misc.constant(-1)
fn_r = fn.math.sqrt( fn.math.dot( fn.coord(), fn.coord() ) )
fn_r2 = (10.*temperature+1.)*fn_r

benFn = fn.branching.conditional( [ (fn.coord()[2] > 0.0, fn_r),
                                    (True               , fn_r2) ] )

model.Solve(fn_k=fn_r, fn_f=1., fn_dBC_inner=2., fn_dBC_outer=0.)
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def fn_r_theta_z(self):
        pos = fn.coord()
        r = fn.math.sqrt(pos[1]**2 + pos[2]**2)
        theta = fn.math.atan2(pos[2],pos[1])
        z = pos[0]
        return r, theta, z
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_r_theta(self):
        pos = fn.coord()
        rFn = fn.math.sqrt(pos[0]**2 + pos[1]**2)
        thetaFn = fn.math.atan2(pos[1],pos[0])
        return rFn, thetaFn
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _fn_unitvec_lon(self):
        pos = fn.coord()
        # r = fn.math.sqrt(pos[0]**2 + pos[1]**2 + pos[2]**2)
        # colat = fn.math.acos(pos[0]/r)
        lon   = fn.math.atan2(pos[2],pos[1])
        vec   = -fn.math.sin(lon) * (0.0, 1.0, 0.0)
        vec  +=  fn.math.cos(lon) * (0.0, 0.0, 1.0)
        return vec
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def fn_r_theta_phi(self):
        pos = fn.coord()
        r = fn.math.sqrt(pos[0]**2 + pos[1]**2 + pos[2]**2)
        theta = fn.math.acos(pos[0]/r)
        phi   = fn.math.atan2(pos[2],pos[1])
        return r, theta, phi
github underworldcode / underworld2 / underworld / mesh / _spherical_mesh.py View on Github external
def _getEWFn(self):
        pos = fn.coord() - self._centroid
        xi = fn.math.atan(pos[0]/pos[2])
        # vec = [ cos(xi), 0.0, -sin(xi) ]
        vec =       fn.math.cos(xi) * (1.,0.,0.)
        vec = vec + fn.math.sin(xi) * (0.,0.,-1.)
        return vec