@* * Copyright 2010-2013 Artima, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@ @import controllers.Application.latestScaladoc @userGuidePage("Testing with mock objects") {
You can use any Java mocking framework with ScalaTest, or ScalaMock, a Scala mocking alternative. ScalaTest provides just enough syntax sugar for the three most popular Java mocking frameworks—JMock, EasyMock, and Mockito—to remove boilerplate and clarify the client code. But other than this minor syntax sugar, the libraries are used from Scala as they are in Java. This enables people familiar with a particular framework to get going quickly and enhances readability for combined Java/Scala projects using a common mocking framework. ScalaMock, the native Scala mocking framework, has been designed to integrate easily into ScalaTest suites.
Here are links to the mocking frameworks described on this page:
ScalaMock is a native, open-source Scala mocking framework written by Paul Butcher that allows you to mock objects and functions.
To use ScalaMock, mix org.scalamock.scalatest.MockFactory
into your Suite
class,
as in:
import org.scalatest.FlatSpec import org.scalamock.scalatest.MockFactory class ExampleSpec extends FlatSpec with MockFactory with ...
Function mocks are created with mockFunction
. The following, for example, creates a mock
function taking a single Int
argument and returning a String
:
val m = mockFunction[Int, String]
You can then set expectations on the mock function. For example, here's how you'd state that you
expect your mock to be called once with the argument 42
, and that when called like that
it should return the string "Forty two"
:
m expects (42) returning "Forty two" once
mock
. The following, for example, creates a mock that implements
all the Turtle
trait (interface):
val turtleMock = mock[Turtle]
You can then set expectations on each of the methods within those traits. Here's an example:
(turtleMock.setPosition _) expects (10.0, 10.0) (turtleMock.forward _) expects (5.0) (turtleMock.getPosition _) expects() returning (15.0, 10.0)
By default, an expectation accepts a single call. The following two statements are equivalent:
(turtleMock.forward_) expects (*) once (turtleMock.forward_) expects (*)
ScalaMock supports two different mocking styles—expectations-first and record-then-verify. These styles can be mixed within a single test.
In the expectations-first style (which was used in previous examples), expectations are set on mock objects before exercising the system under test. If these expectations are not met, the test fails.
You can also use record-then-verify (Mockito) mocking style, where expectations are verified after the system under test has executed.
To use this style usestub
instead of mock
:
val heaterStub = stub[Heater]
Return values that are used by the system under test can be set up by using when
before running the tested system. Calls are verified using verify
:
"CoffeeMachine" should "turn off the heater after coffee making is finished" in { val heaterStub = stub[Heater] val coffeeMachine = new CoffeeMachine(heaterStub) (heaterStub.isReady _).when().returns(true) coffeeMachine.makeCoffee() (heaterStub.setPowerState _).verify(PowerState.On) (heaterStub.setPowerState _).verify(PowerState.Off) }
You can read more about ScalaMock mocking styles in its User Guide.
ScalaMock supports three types of generalised matching:
// expect someMethod("foo", 42) to be called (myMock.someMethod _).expects("foo", 42) // expect someMethod("foo", x) to be called for some integer x (myMock.someMethod _).expects("foo", *) // expect someMethod("foo", x) to be called for some float x that is close to 42.0 (myMock.otherMethod _).expects("foo", ~42.0) // expect sendMessage(receiver, message) for some receiver with name starting with "A" (myMock.sendMessage _).expects(where { (receiver: Player, message: Message) => receiver.name.startsWith("A") })
By default, expectations can be satisfied in any order. A specific sequence can be enforced with inSequence
// expect that machine is turned on before turning it off inSequence { (machineMock.turnOn _).expects() (machineMock.turnOff _).expects() } // players can be fetched in any order inAnyOrder { (databaseMock.getPlayerByName _).expects("Hans") (databaseMock.getPlayerByName _).expects("Boris") }
By default, mocks and stubs expect exactly one call. But you can also specify alternative constraints, for example:
// expect message to be sent twice (myMock.sendMessage _).expects(*).twice // expect message to be sent any number of times (myMock.sendMessage _).expects(*).anyNumberOfTimes // expect message to be sent no more than twice (myMock.sendMessage _).expects(*).noMoreThanTwice
By default mocks and stubs return null
. You can return predefined value using returning()
method (or returns()
in case of stubs).
(databaseMock.getPlayerByName _).expects("Hans").returning(Player(name="Hans", country="Germany")) (databaseMock.getPlayerByName _).expects("Boris").returning(Player(name="Hans", country="Russia"))
throwing
method.
(databaseMock.getPlayerByName _).expects("George").throwing(new NoSuchElementException)
When returned value depends on function arguments, you can return the computed value (or throw a computed exception) with onCall()
.
// compute returned value (fooMock.increment _) expects(*) onCall { arg: Int => arg + 1} fooMock.increment(100) shouldBe 101 // throw computed exception (fooMock.increment _) expects(*) onCall { arg: Int => throw new RuntimeException(arg) }
ScalaTest's EasyMockSugar
trait provides some basic syntax sugar for EasyMock.
Using the EasyMock API directly, you create a mock with:
val mockCollaborator = createMock(classOf[Collaborator])
With this trait, you can shorten that to:
val mockCollaborator = mock[Collaborator]
After creating mocks, you set expectations on them, using syntax like this:
mockCollaborator.documentAdded("Document") mockCollaborator.documentChanged("Document") expectLastCall().times(3)
If you wish to highlight which statements are setting expectations on the mock (versus
which ones are actually using the mock), you can place them in an expecting
clause, provided by this trait, like this:
expecting { mockCollaborator.documentAdded("Document") mockCollaborator.documentChanged("Document") lastCall.times(3) }
Using an expecting
clause is optional, because it does nothing but visually indicate
which statements are setting expectations on mocks. (Note: this trait also provides the lastCall
method, which just calls expectLastCall
.)
Once you've set expectations on the mock objects, you must invoke replay
on
the mocks to indicate you are done setting expectations, and will start using the mock.
After using the mock, you must invoke verify
to check to make sure the mock
was used in accordance with the expectations you set on it. Here's how that looks when you
use the EasyMock API directly:
replay(mockCollaborator) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) verify(mockCollaborator)
This trait enables you to use the following, more declarative syntax instead:
whenExecuting(mockCollaborator) { classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) }
The whenExecuting
method will pass the mockCollaborator
to
replay
, execute the passed function (your code that uses the mock), and
call verify
, passing in the mockCollaborator
. If you want to
use multiple mocks, you can pass multiple mocks to whenExecuting
.
To summarize, here's what a typical test using EasyMockSugar
looks like:
val mockCollaborator = mock[Collaborator]
expecting { mockCollaborator.documentAdded("Document") mockCollaborator.documentChanged("Document") lastCall.times(3) }
whenExecuting(mockCollaborator) { classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) }
An alternative approach is to place your mock objects in a MockObjects
holder object referenced
from an implicit val
, then use the overloaded variant of whenExecuting
that
takes an implicit MockObjects
parameter. Here's how that would look:
implicit val mocks = MockObjects(mock[Collaborator])
expecting { mockCollaborator.documentAdded("Document") mockCollaborator.documentChanged("Document") lastCall.times(3) }
whenExecuting { classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) }
ScalaTest's JMockCycle
class, which wraps and manages the lifecycle of a single org.jmock.Mockery
context object,
provides some basic syntax sugar for using JMock in Scala.
Using the JMock API directly, you first need a Mockery
context object:
val context = new Mockery
JMockCycle
uses jMock's ClassImposterizer
to support mocking of classes, so the following line
would also be needed if you wanted that functionality as well:
context.setImposteriser(ClassImposteriser.INSTANCE)
When using this class, you would instead create an instance of this class (which will create and
wrap a Mockery
object) and import its members, like this:
val cycle = new JMockCycle import cycle._
Using the JMock API directly, you would create a mock object like this:
val mockCollaborator = context.mock(classOf[Collaborator])
Having imported the members of an instance of this class, you can shorten that to:
val mockCollaborator = mock[Collaborator]
After creating mocks, you set expectations on them, using syntax like this:
context.checking( new Expectations() { oneOf (mockCollaborator).documentAdded("Document") exactly(3).of (mockCollaborator).documentChanged("Document") } )
Having imported the members of an instance of this class, you can shorten this step to:
expecting { e => import e._ oneOf (mockCollaborator).documentAdded("Document") exactly(3).of (mockCollaborator).documentChanged("Document") }
The expecting
method will create a new Expectations
object, pass it into
the function you provide, which sets the expectations. After the function returns, the expecting
method will pass the Expectations
object to the checking
method of its internal Mockery
context.
The expecting
method passes an instance of class
org.scalatest.mock.JMockExpectations
to the function you pass into
expectations
. JMockExpectations
extends org.jmock.Expectations
and
adds several overloaded withArg
methods. These withArg
methods simply
invoke corresponding with
methods on themselves. Because with
is
a keyword in Scala, to invoke these directly you must surround them in back ticks, like this:
oneOf (mockCollaborator).documentAdded(`with`("Document"))
By importing the members of the passed JMockExpectations
object, you can
instead call withArg
with no back ticks needed:
oneOf (mockCollaborator).documentAdded(withArg("Document"))
Once you've set expectations on the mock objects, when using the JMock API directly, you use the mock, then invoke
assertIsSatisfied
on the Mockery
context to make sure the mock
was used in accordance with the expectations you set on it. Here's how that looks:
classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) context.assertIsSatisfied()
This class enables you to use the following, more declarative syntax instead:
whenExecuting { classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) }
The whenExecuting
method will execute the passed function, then
invoke assertIsSatisfied
on its internal Mockery
context object.
To summarize, here's what a typical test using JMockCycle
looks like:
val cycle = new JMockCycle import cycle._
val mockCollaborator = mock[Collaborator]
expecting { e => import e._ oneOf (mockCollaborator).documentAdded("Document") exactly(3).of (mockCollaborator).documentChanged("Document") }
whenExecuting { classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) }
ScalaTest also provides a JMockCycleFixture
trait, which
will pass a new JMockCycle
into each test that needs one.
ScalaTest's MockitoSugar
trait provides some basic syntax sugar for Mockito.
Using the Mockito API directly, you create a mock with:
val mockCollaborator = mock(classOf[Collaborator])
Using this trait, you can shorten that to:
val mockCollaborator = mock[Collaborator]
Here is how the example used in the previous EasyMock and JMock sections would look with Mockito and MockitoSugar
:
// First, create the mock object val mockCollaborator = mock[Collaborator] // Create the class under test and pass the mock to it classUnderTest = new ClassUnderTest classUnderTest.addListener(mock) // Use the class under test classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) classUnderTest.addDocument("Document", new Array[Byte](0)) // Then verify the class under test used the mock object as expected verify(mockCollaborator).documentAdded("Document") verify(mockCollaborator, times(3)).documentChanged("Document")
Next, learn about property-based testing.


{% extends 'layouts/main-login.html' %} {% block title %}Success{% endblock %} {% block content %}
It looks like you have an account with us under that email, please check your email and look for a message from<EMAIL_ADDRESS>Once you find it, click the 'reset password' button and you will be navigated back to our site.


Ubuntu/Debian packaging
How to package a C++ program into a debian package
First do all all the steps in:
I will be doing a walk through of the example given in the Packaging New Software in which you will be deploying a simple hello world program.
I first created a directory hello_package, in my ubuntu package deployment workspace, and downloaded the hello world program as outlined in Packaging New Software:
$ pwd
$ /home/username/ubuntu_packaging/hello_package
$ ls
$ hello-2.7 hello-2.7.tar.gz
After building hello-2.7 and installing it, I run bzr dh-make
$ bzr dh-make hello 2.7 hello-2.7.tar.gz
which takes the following options:
bzr dh-make PACKAGE_NAME VERSION TARBALL (see builddeb-plugin)
and creates an additional directory (hello) and new tarball (hello_2.7.orig.tar.gz):
$ pwd
$ /home/username/ubuntu_packaging/hello_package
$ ls
$ hello hello-2.7 hello_2.7.orig.tar.gz hello-2.7.tar.gz
After laboriously changing all files in hello/debian as prescribed and building the debian package more directories are created:
$ pwd
$ /home/username/ubuntu_packaging/hello_package
$ ls
$ build-area hello hello-2.7 hello_2.7-0ubuntu1_amd64.changes hello_2.7-0ubuntu1_amd64.deb hello_2.7-0ubuntu1.debian.tar.gz hello_2.7-0ubuntu1.dsc hello_2.7.orig.tar.gz hello-2.7.tar.gz
- hello_2.7-0ubuntu1_amd64.changes
- hello_2.7-0ubuntu1_amd64.deb
- hello_2.7-0ubuntu1.debian.tar.gz
- hello_2.7-0ubuntu1.dsc
On launchpad you have to create a new PPA for this project and upload your package to it, see PPA-Uploading. Once this is down you are nearly ready to sudo apt-get install this package. Before this you have to add your ppa to your source packages. I ran the following command:
sudo add-apt-repository ppa:gpldecha/ppa-hello
A simple hello program which displays a greeting.
More info: https://launchpad.net/~gpldecha/+archive/ubuntu/ppa-hello
Press [ENTER] to continue or ctrl-c to cancel adding it
Error: signing key fingerprint does not exist
However it did not work, I got: Error: signing key fingerprint does not exist. This is because you frist have to added the public key of the PPA to your package sources, see Added key for signed PPA


You are brainstorming what to scan when a man comes over to you.
The guy has a shirt on featuring a band you haven’t heard of. They look kind of wild in flashy outfits with guitars and whatnot.
The name on the shirt says Parliament Funkadelic.
You strike up a conversation with the man, asking him about the band. Turns out he is an expert on the Parliament Funkadelic band. So much so that he is their "unofficial" historian, he also has a tone of memorabilia connected to the band.


notes: html attr names are case-insensitive (browser sees uppercase char as lowercase) in dom templates, use kebab-case equivalent of camelCase prop


E
Ordinary element
E
Element in conflict
Double click on element will filter all timetable members by teaching group
Loading


seaborn.
hls_palette
(n_colors=6, h=0.01, l=0.6, s=0.65, as_cmap=False)¶Get a set of evenly spaced colors in HLS hue space.
h, l, and s should be between 0 and 1
number of colors in the palette
first hue
lightness
saturation
matplotlib.colors.Colormap
See also
husl_palette
Make a palette using evenly spaced hues in the HUSL system.
Examples
Create a palette of 10 colors with the default parameters:
>>> import seaborn as sns; sns.set_theme()
>>> sns.palplot(sns.hls_palette(10))
Create a palette of 10 colors that begins at a different hue value:
>>> sns.palplot(sns.hls_palette(10, h=.5))
Create a palette of 10 colors that are darker than the default:
>>> sns.palplot(sns.hls_palette(10, l=.4))
Create a palette of 10 colors that are less saturated than the default:
>>> sns.palplot(sns.hls_palette(10, s=.4))


What we must always keep in mind is that the clear determination of goals positively affects the correct prediction of undeniably appropriate objective conditions.
What we must always keep in mind is that the clear determination of goals positively affects the correct prediction of undeniably appropriate objective conditions.
What we must always keep in mind is that clear goal setting positively affects correct prediction
What we must always keep in mind is that clear determination of goals positively affects the correct prediction of conditions undeniably
What we must always keep in mind is that clear goal setting positively affects correct prediction
What we must always keep in mind is that clear goal setting positively affects correct prediction
What we must always keep in mind is that clear determination of goals positively affects the correct prediction of conditions undeniably
What we must always keep in mind is that clear goal setting positively affects correct prediction


Application Program Interface¶
The difference classes in FEniCS Mechanics and member classes are listed here.
Problem Objects¶
The problem classes defining the weak form for mechanics problems are listed here.
Base Mechanics Problem¶
All mechanics problem objects are child classes of
basemechanics.BaseMechanicsProblem
.
-
class
fenicsmechanics.basemechanics.
BaseMechanicsProblem
(user_config)¶ This is the base class for mechanics problems. Checking validity of the ‘config’ dictionary provided by users is done at this level since all mechanics problems are derived from this class. The derived classes will then define the variational problem using the FEniCS UFL language.
For details on the format of the
config
dictionary, check the documentation of the FEniCS Mechanics module by executing>>> import fenicsmechanics as fm >>> help(fm)
-
static
apply_initial_conditions
(init_value, function, function0=0)¶ Assign the initial values to field variables.
Parameters: - init_value (ufl.Coefficient, dolfin.Expression) – A function/expression that approximates the initial condition.
- function (dolfin.Function) – The function approximating a field variable in a mechanics problem.
- function0 (dolfin.Function) – The function approximatinga field variable at the previous time step in a mechanics problem.
Returns: Return type: None
-
check_and_load_mesh
(config)¶ Check the mesh files provided, and load them. Also, extract the geometrical dimension for later use.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_bcs
(config)¶ Check the boundary conditions provided by the user in the config dictionary.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_body_force
(config)¶ Check if body force is specified. If it is, the type is checked, and converted to a ufl.Coefficient object when necessary. If it is not specified, it is set to None.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_config
(user_config)¶ Check that all parameters provided in ‘user_config’ are valid based on the current capabilities of the package. An exception is raised when a parameter (or combination of parameters) is (are) found to be invalid. Please see the documentation of fenicsmechanics for detailed information on the required values.
Parameters: user_config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: config – A copy of user_config with possibly new keys that are needed if they were not originally provided. Return type: dict
-
check_dirichlet
(config)¶ Check if the number of parameters for each key in the dirichlet sub-dictionary are equal. If the key ‘dirichlet’ does not exist, it is added to the dictionary with the value None.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_domain
(config)¶ Check if the domain formulation specified is implemented for the material type.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_finite_element
(config)¶ Check the finite element specified for the numerical formulation of the problem.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_initial_condition
(config)¶ Check if initial condition values were provided. Insert ‘None’ for the values that were not provided.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_material_const_eqn
(config)¶ Check if the material type and the specific constitutive equation specified in the config dictionary are implemented, unless a class is provided. An exception is raised if an unknown material type and/or constitutive equation name is provided.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_material_type
(config)¶ Check if the material type specified is supported.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_neumann
(config)¶ Check if the number of parameters for each key in the neumann sub-dictionary are equal. If the key ‘neumann’ does not exist, it is added to the dictionary with the value None.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
check_time_params
(config)¶ Check the time parameters provided by the user in the config dictionary. Things this function does:
- If the problem is steady, the theta and dt values are set to 1.
- If the problem is unsteady and no value was provided for theta, an exception is raised.
- If the problem is unsteady, and a theta outside of the interval [0, 1] is provided, an exception is raised.
Parameters: config (dict) – Dictionary describing the formulation of the mechanics problem to be simulated. Check the documentation of BaseMechanicsProblem to see the format of the dictionary. Returns: Return type: None
-
static
define_ufl_neumann_form
(regions, types, values, domain, mesh, boundaries, F, J, xi)¶ Define the UFL object representing the variational form of the Neumann boundary.
Parameters: - regions (list, tuple) – List of the region IDs on which Neumann boundary conditions are to be imposed. These IDs must match those used by the mesh function provided. The order must match the order used in the list of types and values.
- types (list, tuple) – List of strings specifying whether a ‘pressure’, ‘piola’, or ‘cauchy’ is provided for each region. The order must match the order used in the list of region IDs and values.
- values (list, tuple) – List of values (dolfin.Constant or dolfin.Expression) for each Dirichlet boundary region specified. The order must match the order used in the list of region IDs and types.
- domain (str) – String specifying whether the problem is to be formulated in terms of Lagrangian, Eulerian, or ALE coordinates. Note: ALE is currently not supported.
- mesh (dolfin.Mesh) – Mesh object used to define a measure.
- boundaries (dolfin.MeshFunction) – Mesh function used to tag different regions of the domain boundary.
- F (ufl object) – Deformation gradient.
- J (ufl object) – Determinant of the deformation gradient.
- xi (dolfin.Argument) – Test function used in variational formulation.
Returns: neumann_form – The UFL Form object defining the variational term(s) corresponding to the Neumann boundary conditions.
Return type: ufl.Form
-
update_bodyforce_time
(t, t0=None)¶ Update the time parameter in the body force expression if it depends on time explicitly.
Parameters: - t (float) – The value to which the user wishes to update the time to.
- t0 (float (default None)) – The previous time value.
Returns: Return type: None
-
update_dirichlet_time
(t)¶ Update the time parameter in the Dirichlet BCs that depend on time explicitly.
Parameters: t (float) – The value to which the users wishes to update the time to. Returns: Return type: None
-
static
update_form_time
(form, t)¶ Update the time of the coefficient objects that depend on it.
Parameters: - form (ufl.Form) – Variational form for which the time is to be updated.
- t (float) – The value to which the time is to be updated.
Returns: Return type: None
-
update_neumann_time
(t, t0=None)¶ Update the time parameter in the Neumann BCs that depend on time explicitly.
Parameters: - t (float) – The value to which the user wishes to update the time to.
- t0 (float (default None)) – The previous time value.
Returns: Return type: None
-
update_time
(t, t0=None)¶ Update the time parameter in the BCs that depend on time explicitly. Also, the body force expression if necessary.
Parameters: - t (float) – The value to which the user wishes to update the time to.
- t0 (float (default None)) – The previous time value.
Returns: Return type: None
-
static
Mechanics Problem¶
-
class
fenicsmechanics.mechanicsproblem.
MechanicsProblem
(user_config)¶ This class represents the variational form of a continuum mechanics problem. The specific form and boundary conditions are generated based on definitions provided by the user in a dictionary of sub-dictionaries.
Refer to the documentation of the FEniCS Mechanics package for details on how to define a problem using the
config
dictionary.>>> import fenicsmechanics as fm >>> help(fm)
-
define_deformation_tensors
()¶ Define kinematic tensors needed for constitutive equations. Tensors that are irrelevant to the current problem are set to 0, e.g. the deformation gradient is set to 0 when simulating fluid flow. Secondary tensors are added with the suffix “0” if the problem is time-dependent. The names of member data added to an instance of the MechanicsProblem class are:
deformationGradient
deformationGradient0
velocityGradient
velocityGradient0
jacobian
jacobian0
-
define_dirichlet_bcs
()¶ Define a list of Dirichlet BC objects based on the problem configuration provided by the user, and add it as member data under ‘dirichlet_bcs’. If no Dirichlet BCs are provided, ‘dirichlet_bcs’ is set to None.
-
define_forms
()¶ Define all of the variational forms necessary for the problem specified by the user and add them as member data. The variational forms are those corresponding to the order reduction of the time derivative (for unsteady solid material simulations), the balance of linear momentum, and the incompressibility constraint.
-
define_function_spaces
()¶ Define the vector (and scalar if incompressible) function spaces based on the degrees specified in config[‘formulation’][‘element’], and add them to the instance of MechanicsProblem as member data. If the material is not incompressible, the scalar function space is set to None.
-
define_functions
()¶ Define the vector and scalar functions necessary to define the problem specified in the ‘config’ dictionary. Functions that are not needed are set to 0. This method calls a method to define the vector functions and another for the scalar functions.
-
define_material
()¶ Create an instance of the class that defining the constitutive equation for the current problem and add it as member data under ‘_material’. All necessary parameters must be included in the ‘material’ subdictionary of ‘config’. The specific values necessary depends on the constitutive equation used. Please check the documentation of the material classes provided in ‘fenicsmechanics.materials’ if using a built-in material.
-
define_scalar_functions
()¶ Define the pressure function(s) necessary to define the problem specified in the ‘config’ dictionary. If the problem is not specified as incompressible, the scalar functions are set to 0. A secondary pressure function with the suffix “0” is also added if the problem is time-dependent to store the pressure values at the previous time step. The names of the member data added to an instance of the MechanicsProblem class are:
test_scalar
trial_scalar
pressure
pressure0
-
define_ufl_body_force
()¶ Define the UFL object corresponding to the body force term in the weak form. The function exits if it has already been defined.
-
define_ufl_convec_accel
()¶ Define the UFL object corresponding to the convective acceleration term in the weak form. The function exits if it has already been defined.
-
define_ufl_convec_accel_diff
()¶ Define the UFL object corresponding to the Gateaux derivative of the convective acceleration term in the weak form. The function exits if it has already been defined.
-
define_ufl_equations
()¶ Define all of the variational forms necessary for the problem specified in the ‘config’ dictionary. This function calls other functions to define the velocity, momentum, and incompressibility equations.
-
define_ufl_equations_diff
()¶ Differentiate all of the variational forms with respect to appropriate fields variables and add as member data.
-
define_ufl_incompressibility_equation
()¶ Define the variational form corresponding to the incompressibility constraint and add as member data.
-
define_ufl_local_inertia
()¶ Define the UFL object corresponding to the local acceleration term in the weak form. The function exits if it has already been defined.
-
define_ufl_local_inertia_diff
()¶ Define the UFL object that describes the matrix that results from taking the Gateaux derivative of the local acceleration term in the weak form. The function exits if it has already been defined.
-
define_ufl_momentum_equation
()¶ Define the variational form corresponding to the balance of linear momentum and add as member data.
-
define_ufl_neumann_bcs
()¶ Define the variational forms for all of the Neumann BCs given in the ‘config’ dictionary under “ufl_neumann_bcs”. If the problem is time-dependent, a secondary variational form is defined at the previous time step with the name “ufl_neumann_bcs0”.
-
define_ufl_neumann_bcs_diff
()¶ Define the derivative(s) of the variational form of the Neumann BCs and add them as member data.
-
define_ufl_stress_work
()¶ Define the UFL object corresponding to the stress tensor term in the weak form. The function exits if it has already been defined.
-
define_ufl_stress_work_diff
()¶ Define the UFL object corresponding to the Gateaux derivative of the stress tensor term in the weak form. The function exits if it has already been defined.
-
define_ufl_velocity_equation
()¶ Define the variational form for the reduction of order equation (equation that relates the velocity and displacement) and add as member data. Note that this is only necessary for time-dependent elastic materials. If this form is not necessary, it is set to 0.
-
define_vector_functions
()¶ Define the vector functions necessary to define the problem specified in the ‘config’ dictionary. If the material is elastic, displacement and velocity functions are defined. Secondary displacement and velocity functions are defined with the suffix “0” if the problem is time-dependent to store the previous time step. Functions that are not needed are set to 0. The trial and test functions for the vector function space are also defined by this function. The names of the member data added to the instance of the MechanicsProblem class are:
test_vector
trial_vector
displacement
displacement0
velocity
velocity0
-
Solid Mechanics Problem¶
-
class
fenicsmechanics.solidmechanics.
SolidMechanicsProblem
(user_config)¶ This class represents the variational form of a solid mechanics problem. The specific form and boundary conditions are generated based on definitions provided by the user in a dictionary of sub-dictionaries.
Refer to the documentation of the FEniCS Mechanics package for details on how to define a problem using the
config
dictionary.>>> import fenicsmechanics as fm >>> help(fm)
-
define_compressible_functions
()¶ Define functions necessary to formulate a compressible solid mechanics problem. The names of the member data added to the instance of the SolidMechanicsProblem class are:
sys_u = ufl_displacement = displacement
: all point to the same displacement function, unlike the incompressible case.sys_du = trial_vector
: trial function for vector function spacetest_vector
: sub component of mixed test functionufl_pressure = pressure = None
If problem is unsteady, the following are also added:
sys_v0 = ufl_velocity0 = velocity0
sys_a0 = ufl_acceleration0 = acceleration0
sys_u0 = ufl_displacement0 = displacement0
-
define_deformation_tensors
()¶ Define kinematic tensors needed for constitutive equations. Secondary tensors are added with the suffix “0” if the problem is time-dependent. The names of member data added to an instance of the SolidMechanicsProblem class are:
deformationGradient
deformationGradient0
jacobian
jacobian0
-
define_dirichlet_bcs
()¶ Define a list of Dirichlet BC objects based on the problem configuration provided by the user, and add it as member data under ‘dirichlet_bcs’. If no Dirichlet BCs are provided, ‘dirichlet_bcs’ is set to None.
-
define_forms
()¶ Define all of the variational forms necessary for the problem specified by the user and add them as member data. The variational forms are those corresponding to the balance of linear momentum and the incompressibility constraint.
-
define_function_assigners
()¶ Create function assigners to update the current and previous time values of all field variables. This is specific to incompressible simulations since the mixed function space formulation requires the handling of the mixed functions and the copies of its subcomponents in a specific manner.
-
define_function_spaces
()¶ Define the function space based on the degree(s) specified in config[‘formulation’][‘element’] and add it as member data. If the problem is specified as incompressible, a mixed function space made up of a vector and scalar function spaces is defined. Note that this differs from MechanicsProblem since there, the vector and scalar function spaces are defined separately.
-
define_functions
()¶ Define mixed functions necessary to formulate the problem specified in the ‘config’ dictionary. The sub-functions are also defined for use in formulating variational forms and saving results separately. Functions that are not needed are set to 0.
-
define_incompressible_functions
()¶ Define mixed functions necessary to formulate an incompressible solid mechanics problem. The mixed function is also split using dolfin.split (for use in UFL variational forms) and u.split(), where u is a mixed function (for saving solutions separately). The names of the member data added to the instance of the SolidMechanicsProblem class are:
sys_u
: mixed functionufl_displacement
: sub component corresponding to displacementdisplacement
: copy of sub component for writing and assigning valuesufl_pressure
: sub component corresponding to pressurepressure
: copy of sub component for writing and assigning valuessys_du
: mixed trial functiontrial_vector
: sub component of mixed trial functiontrial_scalar
: sub component of mixed trial functiontest_vector
: sub component of mixed test functiontest_scalar
: sub component of mixed test function
If problem is unsteady, the following are also added:
ufl_velocity0
: sub component corresponding to velocityvelocity0
: copy of sub component for writing and assigning valuesufl_acceleration0
: sub component corresponding to accelerationacceleration0
: copy of sub component for writing and assigning valuessys_u0
: mixed function at previous time stepufl_displacement0
: sub component at previous time stepdisplacement0
: copy of sub component at previous time stepufl_pressure0
: sub component at previous time steppressure0
: copy of sub component at previous time step
-
define_material
()¶ Create an instance of the class that defines the constitutive equation for the current problem and add it as member data under ‘_material’. All necessary parameters must be included in the ‘material’ subdictionary of ‘config’. The specific values necessary depends on the constitutive equation used. Please check the documentation of the material classes provided in ‘fenicsmechanics.materials’ if using a built-in material.
-
define_ufl_acceleration
()¶ Define the acceleration based on the Newmark integration scheme and add as member data under ‘ufl_acceleration’.
-
define_ufl_body_force
()¶ Define the UFL object corresponding to the body force term in the weak form.
-
define_ufl_equations
()¶ Define all of the variational forms necessary for the problem specified in the ‘config’ dictionary, as well as the mixed variational form.
-
define_ufl_equations_diff
()¶ Differentiate all of the variational forms with respect to appropriate fields variables and add as member data.
-
define_ufl_local_inertia
()¶ Define the UFL object corresponding to the local acceleration term in the weak form.
-
define_ufl_neumann_bcs
()¶ Define the variational forms for all of the Neumann BCs given in the ‘config’ dictionary under “ufl_neumann_bcs”. If the problem is time-dependent, a secondary variational form is defined at the previous time step with the name “ufl_neumann_bcs0”.
-
define_ufl_stress_work
()¶ Define the UFL object corresponding to the stress tensor term in the weak form.
-
Fluid Mechanics Problem¶
-
class
fenicsmechanics.fluidmechanics.
FluidMechanicsProblem
(user_config)¶ This class represents the variational form of a fluid mechanics problem. The specific form and boundary conditions are generated based on definitions provided by the user in a dictionary of sub-dictionaries.
Refer to the documentation of the FEniCS Mechanics package for details on how to define a problem using the
config
dictionary.>>> import fenicsmechanics as fm >>> help(fm)
-
define_compressible_functions
()¶ COMPRESSIBLE FLUIDS ARE CURRENTLY NOT SUPPORTED.
-
define_deformation_tensors
()¶ Define kinematic tensors needed for constitutive equations. Secondary tensors are added with the suffix “0” if the problem is time-dependent. The names of member data added to an instance of FluidMechanicsProblem class are:
velocityGradient
velocityGradient0
-
define_dirichlet_bcs
()¶ Define a list of Dirichlet BC objects based on the problem configuration provided by the user, and add it as member data under ‘dirichlet_bcs’. If no Dirichlet BCs are provided, ‘dirichlet_bcs’ is set to None.
-
define_forms
()¶ Define all of the variational forms necessary for the problem specified by the user and add them as member data. The variational forms are those corresponding to the order reduction of the time derivative (for unsteady solid material simulations), the balance of linear momentum, and the incompressibility constraint.
-
define_function_assigners
()¶ Create function assigners to update the current and previous time values of all field variables. This is specific to incompressible simulations since the mixed function space formulation requires the handling of the mixed functions and the copies of its subcomponents in a specific manner.
-
define_function_spaces
()¶ Define the function space based on the degree(s) specified in config[‘formulation’][‘element’] and add it as member data. If the problem is specified as incompressible, a mixed function space made up of a vector and scalar function spaces is defined. Note that this differs from MechanicsProblem since there, the vector and scalar function spaces are defined separately.
-
define_functions
()¶ Define the vector and scalar functions necessary to define the problem specified in the ‘config’ dictionary. Functions that are not needed are set to 0. This method calls one of two methods to define these functions based depending on whether the fluid is incompressible or not.
-
define_incompressible_functions
()¶ Define mixed functions necessary to formulate an incompressible fluid mechanics problem. The mixed function is also split using dolfin.split (for use in UFL variational forms) and u.split(), where u is a mixed function (for saving solutions separately). The names of the member data added to the instance of the SolidMechanicsProblem class are:
sys_v
: mixed functionufl_velocity
: sub component corresponding to velocityvelocity
: copy of sub component for writing and assigning valuesufl_pressure
: sub component corresponding to pressurepressure
: copy of sub component for writing and assigning valuessys_du
: mixed trial functiontrial_vector
: sub component of mixed trial functiontrial_scalar
: sub component of mixed trial functiontest_vector
: sub component of mixed test functiontest_scalar
: sub component of mixed test function
If problem is unsteady, the following are also added:
sys_v0
: mixed function at previous time stepufl_velocity0
: sub component corresponding to velocityvelocity0
: copy of sub component for writing and assigning valuesufl_pressure0
: sub component at previous time steppressure0
: copy of sub component at previous time step
-
define_material
()¶ Create an instance of the class that defines the constitutive equation for the current problem and add it as member data under ‘_material’. All necessary parameters must be included in the ‘material’ subdictionary of ‘config’. The specific values necessary depends on the constitutive equation used. Please check the documentation of the material classes provided in ‘fenicsmechanics.materials’ if using a built-in material.
-
define_ufl_acceleration
()¶ Define the acceleration based on a single step finite difference and add as member data under ‘ufl_acceleration’.
ufl_acceleration = (ufl_velocity - ufl_velocity0)/dt,
where dt is the size of the time step.
-
define_ufl_body_force
()¶ Define the UFL object corresponding to the body force term in the weak form.
-
define_ufl_convec_accel
()¶ Define the UFL object corresponding to the convective acceleration term in the weak form.
-
define_ufl_equations
()¶ Define all of the variational forms necessary for the problem specified in the ‘config’ dictionary, as well as the mixed variational form.
-
define_ufl_equations_diff
()¶ Differentiate all of the variational forms with respect to appropriate fields variables and add as member data.
-
define_ufl_local_inertia
()¶ Define the UFL object corresponding to the local acceleration term in the weak form.
-
define_ufl_neumann_bcs
()¶ Define the variational forms for all of the Neumann BCs given in the ‘config’ dictionary under “ufl_neumann_bcs”. If the problem is time-dependent, a secondary variational form is defined at the previous time step with the name “ufl_neumann_bcs0”.
-
define_ufl_stress_work
()¶ Define the UFL object corresponding to the stress tensor term in the weak form.
-
Solver Objects¶
Mechanics Solver¶
-
class
fenicsmechanics.mechanicssolver.
MechanicsBlockSolver
(mechanics_problem, fname_disp=None, fname_vel=None, fname_pressure=None, fname_hdf5=None, fname_xdmf=None)¶ This class assembles the UFL variational forms from a MechanicsProblem object, and calls solvers to solve the resulting (nonlinear) algebraic equations. If the problem is time-dependent, this class loops through the time interval specified in the ‘config’ dictionary. An LGMRES algorithm from CBC-Block is used for time-dependent problems. For steady problems, the user may choose from the linear solvers available through dolfin. Furthermore, Newton’s method is used to solve the resulting algebraic equations.
-
nonlinear_solve
(lhs, rhs, bcs, nonlinear_tol=1e-10, iter_tol=1e-08, maxNonlinIters=50, maxLinIters=200, show=0, print_norm=True, lin_solver=’mumps’)¶ Solve the nonlinear system of equations using Newton’s method.
Parameters: - lhs (ufl.Form, list) – The definition of the left-hand side of the resulting linear system of equations.
- rhs (ufl.Form, list) – The definition of the right-hand side of the resulting linear system of equations.
- bcs (dolfin.DirichletBC, list) – Object specifying the Dirichlet boundary conditions of the system.
- nonlinear_tol (float (default 1e-10)) – Tolerance used to terminate Newton’s method.
- iter_tol (float (default 1e-8)) – Tolerance used to terminate the iterative linear solver.
- maxNonlinIters (int (default 50)) – Maximum number of iterations for Newton’s method.
- maxLinIters (int (default 200)) – Maximum number of iterations for iterative linear solver.
- show (int (default 0)) – Amount of information for iterative.LGMRES to show. See documentation of this class for different log levels.
- print_norm (bool (default True)) – True if user wishes to see the norm at every linear iteration and False otherwise.
- lin_solver (str (default "mumps")) – Name of the linear solver to be used for steady compressible elastic problems. See the dolfin.solve documentation for a list of available linear solvers.
Returns: Return type: None
-
solve
(nonlinear_tol=1e-10, iter_tol=1e-08, maxNonlinIters=50, maxLinIters=200, show=0, print_norm=True, save_freq=1, save_initial=True, lin_solver=’mumps’)¶ Solve the mechanics problem defined in the MechanicsProblem object.
Parameters: - nonlinear_tol (float (default 1e-10)) – Tolerance used to terminate Newton’s method.
- iter_tol (float (default 1e-8)) – Tolerance used to terminate the iterative linear solver.
- maxNonlinIters (int (default 50)) – Maximum number of iterations for Newton’s method.
- maxLinIters (int (default 200)) – Maximum number of iterations for iterative linear solver.
- show (int (default 0)) – Amount of information for iterative.LGMRES to show. See documentation of this class for different log levels.
- print_norm (bool (default True)) – True if user wishes to see the norm at every linear iteration and False otherwise.
- save_freq (int (default 1)) – The frequency at which the solution is to be saved if the problem is unsteady. E.g., save_freq = 10 if the user wishes to save the solution every 10 time steps.
- save_initial (bool (default True)) – True if the user wishes to save the initial condition and False otherwise.
- lin_solver (str (default "mumps")) – Name of the linear solver to be used for steady compressible elastic problems. See the dolfin.solve documentation for a list of available linear solvers.
Returns: Return type: None
-
time_solve
(nonlinear_tol=1e-10, iter_tol=1e-08, maxNonlinIters=50, maxLinIters=200, show=0, print_norm=True, save_freq=1, save_initial=True, lin_solver=’mumps’)¶ Loop through the time interval using the time step specified in the MechanicsProblem config dictionary.
Parameters: - nonlinear_tol (float (default 1e-10)) – Tolerance used to terminate Newton’s method.
- iter_tol (float (default 1e-8)) – Tolerance used to terminate the iterative linear solver.
- maxNonlinIters (int (default 50)) – Maximum number of iterations for Newton’s method.
- maxLinIters (int (default 200)) – Maximum number of iterations for iterative linear solver.
- show (int (default 0)) – Amount of information for iterative.LGMRES to show. See documentation of this class for different log levels.
- print_norm (bool (default True)) – True if user wishes to see the norm at every linear iteration and False otherwise.
- save_freq (int (default int)) – The frequency at which the solution is to be saved if the problem is unsteady. E.g., save_freq = 10 if the user wishes to save the solution every 10 time steps.
- save_initial (bool (default True)) – True if the user wishes to save the initial condition and False otherwise.
- lin_solver (str (default "mumps")) – Name of the linear solver to be used for steady compressible elastic problems. See the dolfin.solve documentation for a list of available linear solvers.
Returns: Return type: None
-
ufl_lhs_rhs
()¶ Return the UFL objects that define the left and right hand sides of the resulting linear system for the variational problem defined by the MechanicsProblem object.
-
update_soln
(du)¶ Update the values of the field variables based on the solution to the resulting linear system.
Parameters: du (block.block_vec, dolfin.Vector) – The solution to the resulting linear system of the variational problem defined by the MechanicsProblem object. Returns: Return type: None
-
Base Mechanics Solver¶
The SolidMechanicsSolver
and FluidMechanicsSolver
classes inherit from both dolfin.NonlinearVariationalSolver
and basemechanics.BaseMechanicsSolver
.
-
class
fenicsmechanics.basemechanics.
BaseMechanicsSolver
(problem, fname_pressure=None, fname_hdf5=None, fname_xdmf=None)¶ This is the base class for mechanics solvers making use of the FEniCS mixed function space functionality. Methods common to all mechanics solvers are defined here.
-
full_solve
(save_freq=1, save_initial=True)¶ Solve the mechanics problem defined by SolidMechanicsProblem. If the problem is unsteady, this function will loop through the entire time interval using the parameters provided for the Newmark integration scheme.
Parameters: - save_freq (int (default 1)) – The frequency at which the solution is to be saved if the problem is unsteady. E.g., save_freq = 10 if the user wishes to save the solution every 10 time steps.
- save_initial (bool (default True)) – True if the user wishes to save the initial condition and False otherwise.
Returns: Return type: None
-
set_parameters
(linear_solver=’default’, preconditioner=’default’, newton_abstol=1e-10, newton_reltol=1e-09, newton_maxIters=50, krylov_abstol=1e-08, krylov_reltol=1e-07, krylov_maxIters=50)¶ Set the parameters used by the NonlinearVariationalSolver.
Parameters: - linear_solver (str) – The name of linear solver to be used.
- newton_abstol (float (default 1e-10)) – Absolute tolerance used to terminate Newton’s method.
- newton_reltol (float (default 1e-9)) – Relative tolerance used to terminate Newton’s method.
- newton_maxIters (int (default 50)) – Maximum number of iterations for Newton’s method.
- krylov_abstol (float (default 1e-8)) – Absolute tolerance used to terminate Krylov solver methods.
- krylov_reltol (float (default 1e-7)) – Relative tolerance used to terminate Krylov solver methods.
- krylov_maxIters (int (default 50)) – Maximum number of iterations for Krylov solver methods.
Returns: Return type: None
-
step
()¶ Compute the solution for the next time step in the simulation. Note that there is only one “step” if the simulation is steady.
-
update_assign
()¶ This method is meant to update the state of the system and assign to the proper dolfin.Function objects. It is to be overwritten by the specific solver object, and hence will raise an exception at this level.
-
Solid Mechanics Solver¶
-
class
fenicsmechanics.solidmechanics.
SolidMechanicsSolver
(problem, fname_disp=None, fname_pressure=None, fname_hdf5=None, fname_xdmf=None)¶ This class is derived from the dolfin.NonlinearVariationalSolver to solve problems formulated with SolidMechanicsProblem. It passes the UFL variational forms to the solver, and loops through all time steps if the problem is unsteady. The solvers that are available through this class are the same as those available through dolfin. The user may use the helper function, ‘set_parameters’ to set the linear solver used, as well as the tolerances for iterative and nonlinear solves, or do it directly through the ‘parameters’ member.
-
static
update
(u, u0, v0, a0, beta, gamma, dt)¶ Function to update values of field variables at the current and previous time steps based on the Newmark integration scheme:
a = 1.0/(beta*dt^2)*(u - u0 - v0*dt) - (1.0/(2.0*beta) - 1.0)*v0 v = dt*((1.0 - gamma)*a0 + gamma*a) + v0
This particular method is to be used when the function objects do not derive from a mixed function space.
Parameters: - u (dolfin.Function) – Object storing the displacement at the current time step.
- u0 (dolfin.Function) – Object storing the displacement at the previous time step.
- v0 (dolfin.Function) – Object storing the velocity at the previous time step.
- a0 (dolfin.Function) – Object storing the acceleration at the previous time step.
- beta (float) – Scalar parameter for the family of Newmark integration schemes. See equation above.
- gamma (float) – Scalar parameter for the family of Newmark integration schemes. See equation above.
- dt (float) – Time step used to advance through the entire time interval.
Returns: Return type: None
-
update_assign
()¶ Update the values of the field variables – both the current and previous time step in preparation for the next step of the simulation.
-
static
Fluid Mechanics Solver¶
-
class
fenicsmechanics.fluidmechanics.
FluidMechanicsSolver
(problem, fname_vel=None, fname_pressure=None, fname_hdf5=None, fname_xdmf=None)¶ This class is derived from the dolfin.NonlinearVariationalSolver to solve problems formulated with FluidMechanicsProblem. It passes the UFL variational forms to the solver, and loops through all time steps if the problem is unsteady. The solvers that are available through this class are the same as those available through dolfin. The user may use the helper function, ‘set_parameters’ to set the linear solver used, as well as the tolerances for iterative and nonlinear solves, or do it directly through the ‘parameters’ member.
-
update_assign
()¶ Update the values of the field variables – both the current and previous time step in preparation for the next step of the simulation.
-
Constitutive Equations¶
The materials
submodule implements some common constitutive
equations for users to take advantage of.
Solid Materials¶
This module contains classes that define the stress tensor for various
solid materials. The parent class ElasticMaterial
is used for
all class definitions. Then materials are separated into isotropic and
anisotropic using IsotropicMaterial
and
AnisotropicMaterial
.
Parameters required by each constitutive equation is case-dependent. Thus, the user should check that particular documentation.
-
class
fenicsmechanics.materials.solid_materials.
LinearIsoMaterial
(inverse=False, **params)¶ Return the Cauchy stress tensor based on linear elasticity, i.e. infinitesimal deformations, both compressible and incompressible. The stress tensor is given by
- Compressible: \(\mathbf{T} = \lambda\text{tr}(\mathbf{e})\mathbf{I} \ + 2\mu\mathbf{e}\),
- Incompressible: \(\mathbf{T} = -p\mathbf{I} + 2\mu\mathbf{e}\),
where \(\lambda\) and \(\mu\) are the Lame material parameters, \(\mathbf{e} = \text{sym}(\text{grad}(\mathbf{u}))\) where \(\mathbf{u}\) is the displacement, and \(p\) is the pressure in the case of an incompressible material.
The inverse elastostatics formulation is also supported for this material model. In that case, the only change that must be accounted for is the fact that
\[\mathbf{e} = \text{sym}(\mathbf{f}^{-1}) - \mathbf{I},\]where \(\mathbf{f} = \mathbf{F}^{-1}\) is the deformation gradient from the current to the reference configuration.
At least two of the material constants from the list below must be provided in the
'material'
subdictionary ofconfig
in addition to the values already listed in the docstring offenicsmechanics
. The remaining constants will be computed based on the parameters provided by the user.Parameters: - 'la' (float) – The first Lame parameter used as shown in the equations above. Note: providing la and inv_la does not qualify as providing two material constants.
- 'mu' (float) – The second Lame parameter used as shown in the equations above.
- 'kappa' (float) – The bulk modulus of the material.
- 'inv_la' (float) – The reciprocal of the first Lame parameter, la. Note: providing la and inv_la does not qualify as providing two material constants.
- 'E' (float) – The Young’s modulus of the material.
- 'nu' (float) – The Poisson’s ratio of the material.
-
incompressibilityCondition
(u)¶ Return the incompressibility condition for a linear material, \(p = \kappa\text{div}(\mathbf{u})\).
Parameters: u (dolfin.Function, ufl.tensors.ListTensor) – The displacement vector. Returns: Bvol – UFL object defining the incompressibility condition. Return type: ufl.algebra.Product
-
stress_tensor
(F, J, p=None, formulation=None)¶ Return the Cauchy stress tensor for a linear material, namely:
- Compressible: \(\mathbf{T} = \lambda\text{tr}(\mathbf{e})\mathbf{I} \ + 2\mu\mathbf{e}\),
- Incompressible: \(\mathbf{T} = -p\mathbf{I} + 2\mu\mathbf{e}\),
Parameters: - F (ufl.algebra.Sum) – The deformation gradient.
- J (ufl.tensoralgebra.Determinant) – The Jacobian, i.e. determinant of the deformation gradient. Note that this is not used for this material. It is solely a place holder to conform to the format of other materials.
- p (ufl.Coefficient (default, None)) – The UFL pressure function for incompressible materials.
- formulation (str (default, None)) – This input is not used for this material. It is solely a place holder to conform to the format of other materials.
Returns: T – The Cauchy stress tensor given by the equation above.
Return type: ufl.algebra.Sum
-
class
fenicsmechanics.materials.solid_materials.
NeoHookeMaterial
(inverse=False, **params)¶ Return the first Piola-Kirchhoff stress tensor based on variations of the strain energy function
\[\psi(\mathbf{C}) = \frac{1}{2}\mu(\text{tr}(\mathbf{C}) - n),\]where \(\mathbf{C} = \mathbf{F}^T\mathbf{F}\), and \(n\) is the geometric dimension. For nearly incompressible materials, the total strain energy function is given by
\[W = U(J) + \psi(\mathbf{C}),\]where \(U(J)\) corresponds to the strain energy in response to dilatation of the material with \(J = \det(\mathbf{F})\). The two forms of \(U(J)\) supported here are
- Square: \(U(J) = \frac{1}{2}\kappa(J - 1)^2\),
- Log: \(U(J) = \frac{1}{2}\kappa(\ln(J))^2\),
where \(\kappa\) is the bulk modulus of the material. This results in the first Piola-Kirchhoff stress tensor given by
\[\mathbf{P} = J\frac{dU}{dJ}\mathbf{F}^{-T} + \mu\mathbf{F}.\]In the case of an incompressible material, the total strain energy is assumed to be of the form
\[W = U(J) + \psi(\bar{\mathbf{C}}),\]where \(\bar{\mathbf{C}} = J^{-2/n}\mathbf{C}\). Furthermore, the pressure scalar field is defined such that \(p = -\frac{dU}{dJ}\). The resulting first Piola-Kirchhoff stress tensor is then
\[\mathbf{P} = -\left[Jp + \frac{1}{n}\mu J^{-2/n}\text{tr}(\mathbf{C}) \right]\mathbf{F}^{-T} + \mu J^{-2/n}\mathbf{F}.\]The inverse elastostatics formulation is also supported for this material model. In that case, the Cauchy stress tensor for compressible material is
\[\mathbf{T} = -j^2\frac{dU}{dj}\mathbf{I} + \mu\mathbf{c}^{-1},\]and
\[\mathbf{T} = -\left[p + \frac{1}{n}\mu j^{-1/n}i_2\right]\mathbf{I} + \mu j^{5/n}\mathbf{c}^{-1},\]for incompressible material where \(j = \det(\mathbf{f}) = \ \det(\mathbf{F}^{-1}) = \frac{1}{J}, \mathbf{c} = \mathbf{f}^T\mathbf{f}\), \(i_2\) is the second invariant of c, and p is the pressure in the latter case. Note that \(\mathbf{f}\) is the deformation gradient from the current configuration to the reference configuration.
At least two of the material constants from the list below must be provided in the
'material'
subdictionary ofconfig
in addition to the values already listed in the docstring offenicsmechanics
.Parameters: - 'la' (float) – The first parameter used as shown in the equations above. Note: providing
la
andinv_la
does not qualify as providing two material parameters. - 'mu' (float) – The second material parameter used as shown in the equations above.
- 'kappa' (float) – The bulk modulus of the material.
- 'inv_la' (float) – The reciprocal of the first parameter,
la
. Note: providingla
andinv_la
does not qualify as providing two material parameters. - 'E' (float) – The Young’s modulus of the material. Note: this is not entirely consistent
with the neo-Hookean formulation, but
la
andmu
will be computed based on the relation between the Young’s modulus and the Lame parameters ifE
is given. - 'nu' (float) – The Poisson’s ratio of the material. Note: this is not entirely consistent
with the neo-Hookean formulation, but
la
andmu
will be computed based on the relation between the Poisson’s ratio and the Lame parameters ifnu
is given.
-
strain_energy
(F, J, formulation=None)¶ Define the total strain energy based on the incompressibility of the material (fully or nearly incompressible, or compressible), defined with respect to the deformation gradient, or by its inverse if the objective is to find the inverse displacement. The strain energy for a compressible material is defined by
\[\begin{split}W = \frac{1}{2}\mu(I_1 - n) + \frac{1}{2}\lambda(\ln(J))^2 - \mu\ln(J) \\ = \frac{1}{2}\mu\left(\frac{i_2}{i_3} - n\right) + \frac{1}{2}\lambda(\ln(j))^2 - \mu\ln(j),\end{split}\]where \(I_1\) is the first invariant of \(\mathbf{C} = \ \mathbf{F}^T\mathbf{F}\), while \(i_2\) and \(i_3\) are the second and third invariants of \(\mathbf{c} = \mathbf{f}^T \ \mathbf{f}\), with \(\mathbf{f} = \mathbf{F}^{-1}\). For a (nearly-)incompressible material, the strain energy is defined by
\[\begin{split}W = U(J) + \frac{1}{2}\mu(I_1 - n) \\ = U(j) + \frac{1}{2}\mu(\frac{i_2}{i_3} - n),\end{split}\]where the invariants are now those of \(\bar{\mathbf{C}} = \ J^{-2/n}\mathbf{C}\) or \(\bar{\mathbf{c}} = j^{-2/n}\mathbf{c}\), and \(\frac{dU}{dJ} = p\) for fully incompressible material, while \(U(J) = \kappa\phi(J)\). The two forms of \(\phi(J)\) supported here are
- Square: \(\phi(J) = \frac{1}{2}(J - 1)^2\),
- Log: \(\phi(J) = \frac{1}{2}(\ln(J))^2\).
Parameters: - F (ufl.algebra.Sum) – The (forward or inverse) deformation gradient.
- J (ufl.tensoralgebra.Determinant) – The jacobian, i.e. determinant of the deformation gradient given above.
- formulation (str (default, None)) – The formulation used for the nearly-incompressible materials.
Value must either be
'square'
or'log'
.
Returns: W – The strain energy defined above.
Return type: ufl.algebra.Sum
-
stress_tensor
(F, J, p=None, formulation=None)¶ Return the first Piola-Kirchhoff stress tensor for a neo-Hookean material. The stress tensor is given by
Compressible:
\[\mathbf{P} = J\frac{dU}{dJ}\mathbf{F}^{-T} + \mu\mathbf{F}\]Incompressible:
\[\mathbf{P} = \left[-Jp - \frac{\mu J^{-2/n}}{n}\text{tr}(\mathbf{C}) \ \right]\mathbf{F}^{-T} + \mu J^{-2/n}\mathbf{F},\]
where \(\mathbf{F}\) is the deformation gradient, \(J = \ \det(\mathbf{F})\), \(\mathbf{C} = \mathbf{F}^T\mathbf{F}\), and \(\mu\) is a material constant. If the problem is an inverse elastostatics problem, the Cauchy stress tensor is given by
Compressible:
\[\mathbf{T} = \left[-j^2\frac{dU}{dj} - \frac{\mu j^{-1/n}}{n}i_2 \ \right]\mathbf{I} + \mu j^{-5/n}\mathbf{c}^{-1}\]Incompressible:
\[\mathbf{T} = -\left[p + \frac{\mu j^{-1/n}}{n}i_2 \ \right]\mathbf{I} + \mu j^{-5/n}\mathbf{c}^{-1}\]
where \(\mathbf{f} = \mathbf{F}^{-1}\), \(j = \det(\mathbf{f})\), \(\mathbf{c} = \mathbf{f}^T\mathbf{f}\), and \(n\) is the geometric dimension.
Parameters: - F (ufl.algebra.Sum) – The deformation gradient.
- J (ufl.tensoralgebra.Determinant) – The Jacobian, i.e. determinant of the deformation gradient.
- p (dolfin.Function, ufl.indexed.Indexed (default, None)) – The pressure for incompressible materials.
- formulation (str (default, None)) – The formulation used for the strain energy due to dilatation of the material.
Returns: P – The first Piola-Kirchhoff stress tensor for forward problems and the Cauchy stress tensor for inverse elastostatics problems.
Return type: ufl.algebra.Sum
-
class
fenicsmechanics.materials.solid_materials.
FungMaterial
(mesh, inverse=False, **params)¶ This class defines the stress tensor for Fung type materials which are based on the strain energy function given by
\[W = C\exp(Q),\]where
\[Q = d_1 E_{11}^2 + d_2 E_{22}^2 + d_3 E_{33}^2 + 2(d_4 E_{11}E_{22} + d_5 E_{22}E_{33} + d_6 E_{11}E_{33}) + d_7 E_{12}^2 + d_8 E_{23}^2 + d_9 E_{13}^2,\]and \(C\) and \(d_i, i = 1,...,9\) are material constants. The \(E_{ij}\) components here are the components of the Lagrangian strain tensor,
\[\mathbf{E} = \frac{1}{2}(\mathbf{F}^T\mathbf{F} - \mathbf{I}),\]with respect to the orthonormal set \(\{\mathbf{e}_1, \mathbf{e}_2, \ \mathbf{e}_3\}\), where \(\mathbf{e}_1\) is a fiber direction, \(\mathbf{e}_2\) the direction normal to the fiber, and \(\mathbf{e}_3 = \mathbf{e}_1 \times \mathbf{e}_2\).
The resulting first Piola-Kirchhoff stress tensor is then
\[\mathbf{P} = \mathbf{P}_{vol} + \mathbf{P}_{iso}\]with
\[\mathbf{P}_{iso} = J^{-2/n}\mathbf{F}\hat{\mathbf{S}} - \frac{1}{n}J^{-2/n}\text{tr}(\mathbf{C}\hat{\mathbf{S}}) \mathbf{F}^{-T},\]and
\[\hat{\mathbf{S}} = C\exp(Q)\left( (d_1 E_{11} + d_4 E_{22} + d_6 E_{33}) \text{outer}(\mathbf{e}_1, \mathbf{e}_1) + (d_4 E_{11} + d_2 E_{22} + d_5 E_{33}) \text{outer}(\mathbf{e}_2, \mathbf{e}_2) + (d_6 E_{11} + d_5 E_{22} + d_3 E_{33}) \text{outer}(\mathbf{e}_3, \mathbf{e}_3) + d_7 E_{12}(\text{outer}(\mathbf{e}_1, \mathbf{e}_2) + \text{outer}(\mathbf{e}_2, \mathbf{e}_1)) + d_9 E_{13}(\text{outer}(\mathbf{e}_1, \mathbf{e}_3) + \text{outer}(\mathbf{e}_3, \mathbf{e}_1)) + d_8 E_{23}( text{outer}(\mathbf{e}_2, \mathbf{e}_3) + \text{outer}(\mathbf{e}_3, \mathbf{e}_2))\right).\]For compressible materials,
\[\mathbf{P}_{vol} = 2J\kappa(J - \frac{1}{J})\mathbf{F}^{-T},\]and
\[\mathbf{P}_{vol} = -Jp\mathbf{F}^{-T}\]for incompressible, where \(\kappa\) is the bulk modulus, and \(p\) is the pressure.
The inverse elastostatics formulation for this material is supported. The constitutive equation remains the same, but the Lagrangian strain is defined in terms of the \(\mathbf{f} = \mathbf{F}^{-1}\), i.e.
\[\mathbf{E} = \frac{1}{2}((\mathbf{ff}^T)^{-1} - \mathbf{I}).\]Furthermore, \(\mathbf{F} = \mathbf{f}^{-1}\) is substituted, and the stress tensor returned is the Cauchy stress tensor given by \(\mathbf{T} \ = j\mathbf{Pf}^{-T}\), where \(j = \det(\mathbf{f})\).
In addition to the values listed in the docstring of
fenicsmechanics
for the ‘material’ subdictionary of ‘config’, the user must provide the values listed below.Parameters: - 'fibers' (dict) – See AnisotropicMaterial for details.
- 'C' (float) – Material constant that can be thought of as “stiffness” in some limiting cases.
- 'd' (list, tuple) – A list containing the coefficients in the exponent, Q, defined above.
- 'kappa' (float) – The bulk modulus of the material.
-
stress_tensor
(F, J, p=None, formulation=None)¶ Return the first Piola-Kirchhoff stress tensor for forward problems and the Cauchy stress tensor for inverse elastostatics problems. The constitutive equation is shown in the documentation of FungMaterial.
Parameters: - F (ufl.algebra.Sum) – The deformation gradient.
- J (ufl.tensoralgebra.Determinant) – The Jacobian, i.e. the determinant of the deformation gradient.
- p (dolfin.Function, ufl.indexed.Indexed (default, None)) – The pressure function for incompressible materials.
- formulation (str (default, None)) – This input is not used for this material. It is solely a place holder to conform to the format of other materials.
Returns: P – The stress tensor defined in the FungMaterial documentation.
Return type: ufl.algebra.Sum
-
class
fenicsmechanics.materials.solid_materials.
GuccioneMaterial
(mesh, inverse=False, **params)¶ This class defines the stress tensor for Guccione type materials, which are a subclass of Fung-type materials. The constitutive equation is the same as that found in the FungMaterial documentation, but with
\[Q = b_f E_{11}^2 + b_t (E_{22}^2 + E_{33}^2 + 2 E_{23}^2) + 2b_{fs}(E_{12}^2 + E_{13}^2),\]where \(b_f\), \(b_t\), and \(b_{fs}\) are the material parameters. The relation between these material constants and the \(d_i, i = 1,...,9\) can be obtained in a straight-forward manner.
Note that the inverse elastostatics formulation is also supported since this class is derived from FungMaterial.
In addition to the values listed in the documentation for
fenicsmechanics
for the'material'
subdictionary of ‘config’, the user must provide the following values:Parameters: - 'fibers' (dict) – See AnisotropicMaterial for details.
- 'C' (float) – Material constant that can be thought of as “stiffness” in some limiting cases.
- 'bf' (float) – Material “stiffness” in the fiber direction.
- 'bt' (float) – Material “stiffness” in transverse directions.
- 'bfs' (float) – Material rigidity under shear.
-
strain_energy
(u, p=None)¶ Return the strain energy of Guccione material defined in the documentation of GuccioneMaterial.
Parameters: - u (dolfin.Funcion, ufl.tensors.ListTensor) – The displacement of the material.
- p (dolfin.Function, ufl.indexed.Indexed (default, None)) – The pressure for incompressible materials.
Returns: W – The strain energy defined in the documentation of GuccioneMaterial.
Return type: ufl.algebra.Sum
Fluids¶
-
class
fenicsmechanics.materials.fluids.
NewtonianFluid
(**params)¶ Class defining the stress tensor for an incompressible Newtonian fluid. Currently, only incompressible fluids are supported. The Cauchy stress tensor is given by
\[\mathbf{T} = -p\mathbf{I} + 2\mu\text{Sym}(\mathbf{L}),\]where \(p\) is the pressure, \(\mathbf{I}\) is the identity tensor, \(\mu\) is the dynamic viscosity of the fluid, and \(\mathbf{L} = \text{grad}(\mathbf{v})\), where \(\mathbf{v}\) is the velocity vector field.
In addition to the values listed in the documentation of
fenicsmechanics
for the'material'
subdictionary of ‘config’, the user must provide at least one of the values listed below:Parameters: - 'mu' (float) – Dynamic viscosity of the fluid.
- 'nu' (float) – Kinematic viscosity of the fluid.
-
stress_tensor
(L, p)¶ Return the Cauchy stress tensor for an incompressible Newtonian fluid, namely
\[\mathbf{T} = -p\mathbf{I} + 2\mu\text{Sym}(\mathbf{L}),\]where \(\mathbf{L} = \text{grad}(\mathbf{v})\), \(\mathbf{I}\) is the identity tensor, \(p\) is the hydrostatic pressure, and \(\mu\) is the dynamic viscosity.
Parameters: - L (ufl.differentiation.Grad) – The velocity gradient.
- p (dolfin.Function, ufl.indexed.Indexed) – The hydrostatic pressure.
Returns: T – The Cauchy stress tensor defined above.
Return type: ufl.algebra.Sum


donate if you enjoy my work :) Try multiple monitors or a phone Hotkeys: F11 = fullscreen m = toggle mute h = toggle help c = toggle controls +/- = adjust volume 5% left arrow = go back 30s right arrow = go forward 30s down arrow = move to beginning up arrow = move to end p or pause = toggle pause/play enter = toggle search r = load search results for all videos 1-9 = load search results in one


Release date: {{singleMovie.releaseDate | date:'longDate'}}
Total vote counts: {{singleMovie.voteCount}}
Average vote: {{singleMovie.voteAverage}} out of 5


--- layout: post title: "My Week in Review" date: 2017-01-01 05:05:00 +0000 tags: image: https://s3.amazonaws.com/audreywatters/2017-01-01-fireworks.jpg imagecredits: https://www.flickr.com/photos/cogdog/5904282216 ---
Icon credits: The Noun Project


continue →
↑ swipe up for appendix ↑
↓ swipe down to return to art ↓
TAP
Nhwe I eernetd eamyetlenr oohlcs, I dah a tsngor scpeeh nmimpediet inclgudin a lisp dna tsom eelopp had a hadr emit nagdtnnerusdi em. Bescuea my ddpoeta Keonra stiers doclu nertduadns em, plepeo ssdumea I was ipkngsae ni Knoear adn ehs saw iatntsrangl for em. Ni drroe to overmeco my spehce imeipnmdet, I was ents ot icepasl dcuieoant sessalc to ahev rloa-oortm speehc parhtye. I zyahli ermbemre tsniitg ni a rcloasoms tiwh lhdrcnie ttha had naeltm dna phlcysia dibssieitial nad nto tsrdanedinung what ym oprelmb was. I didn’t ndureadsnt taht on one utiosed fo ym mateeidmi imaylf had orlutbe unaidderngnst em.
Appendix


| Supplement Facts |
|
|
| Serving Size: 1 Tablet |
|
|
| Amount per Serving |
|
* % DV |
| Iron( from ferrous fumarate) |
106 mg |
588.9 % |
| * Percent daily value based on 2,000 calorie diet |
|
|
Indications
A hematinic supplement for iron deficiency anemia
SIDE EFFECTS: Gastrointestinal disturbances (anorexia, nausea, diarrhea, constipation) occur occasionally but are ussually mild and subside with continuation of therapy.
|
WARNING: Accidental overdose of iron-containing products is a leading cause of fatal poisoning in children under 6. Keep this product out of reach of children. In case of accidental overdose, call a doctor or poison control center immediately. |
If you are pregnant or nursing a baby, seek the advice of a health professional before using the product.
Do not purchase if any portion of product is opened.
You should contact your healthcare provider for medical advice about adverse events. To report a serious adverse event, contact US Pharmaceutical Corporation, P.O Box 360465, Decatur,GA 30036
Store at controlled room temperature between 15° to 30°C (59° to 86 °F ). Keep in a cool ,dry place. Capsules are not USP
DOSAGE:Adults (persons over 12 years of age), one (1) tablet daily, between meals, or as prescribed by a physician. Do not exceed recommended dosage. Do not administer to children under the age of 12.
HOW SUPPLIED: Hemocyte is a round, dark red film coated tablet debossed with the "US" logo on one side . Hemocyte is supplied in boxes of 30 tablets, NDC 52747-307-30 and 100 tablets, NDC 52747-307-70
A hematinic supplement for iron deficiency anemia
Packaging


An equilateral triangle is one where all sides of the triangle are equal An isosceles triangle is one where two sides are exactly equal while a scalene triangle is one that has all sides differing in length.
length 1:
length 2:
length 3: IDENTIFY


The comake vision
Join comake and revolutionize democracy! We help you and your neighbours communicate with your representatives and homeowner associations to resolve issues facing your communities!
The comake solution
- Frustrated that issues in your community take a long time—if ever—to be addressed?
- Apathetic toward local politics because you never see anything being done?
- Confused over who to talk to get issues resolved?


I measure every Grief I meet
With narrow, probing, eyes —
I wonder if It weighs like Mine —
Or has an Easier size.
I wonder if They bore it long —
Or did it just begin —
I could not tell the Date of Mine —
It feels so old a pain —
I wonder if it hurts to live —
And if They have to try —
And whether — could They choose between —
It would not be — to die —
I note that Some — gone patient long —
At length, renew their smile —
An imitation of a Light
That has so little Oil —
I wonder if when Years have piled —
Some Thousands — on the Harm —
That hurt them early — such a lapse
Could give them any Balm —
Or would they go on aching still
Through Centuries of Nerve —
Enlightened to a larger Pain —
In Contrast with the Love —
The Grieved — are many — I am told —
There is the various Cause —
Death — is but one — and comes but once —
And only nails the eyes —
There—s Grief of Want — and grief of Cold —
A sort they call “Despair” —
There—s Banishment from native Eyes —
In sight of Native Air —
And though I may not guess the kind —
Correctly — yet to me
A piercing Comfort it affords
In passing Calvary —
To note the fashions — of the Cross —
And how they're mostly worn —
Still fascinated to presume
That Some — are like my own —


What's new?
- Support for Lua 5.2, while being able to execute in Lua 5.1 with module <%=link"LuaCompat52"%>.
- Support for constants (ConstantDef) in the OiL internal interface repository.
- Support for GIOP 1.2 and Bi-Directional GIOP.
- Support for timeout on method invocation (see <%=link("Reference.orb:settimeout")%> and <%=link("Reference.proxy:__settimeout")%>) and in processing invocations (see <%=link("Reference.orb:step")%>).
- Support for an error handling function for servant dispatch errors (see <%=link("Reference.orb:setexhandler")%>).
- Support for a notification function of uncaught ORB error (see <%=link("Reference.orb:setonerror")%>).
- Support for definition of timeout of TCP sockets used by the ORB (see <%=link("Reference.tcpopt.timeout")%>).
- New operation to recover ORB's interceptors (see <%=link("Reference.orb:getinterceptor")%>).
- New ORB initialization option to recover control local reference resolution (see <%=link("Reference.orbcfg.localrefs")%>).
- New version of LuDO (incompatible with the previous one)
What changed?
- Improved Features
-
- Adjustment to show expections correctly when using function <%=link("Reference.oil.main")%>.
- New field <%=link("Reference.reqcli.profile_data")%> in intercepted client request that contains provides the encoded profile used for connection.
Old field
profile_data
with the decoded profile information was renamed to <%=link("Reference.reqcli.profile")%>.
- Adjustments in the way CORBA interceptor methods are invoked in case the request is forwarded.
Now, every time an interceptor forwards a request, the interceptor methods are invoked again for the forwarded request.
- Field <%=link("Reference.request.service_context")%> of CORBA intercepted requests becomes a map instead of an array to adhere better to the limitations imposed by the CORBA Portable Interceptors.
In particular, to avoid the application to send more than one service context with the same ID (tag).
- Add support for binary files in functions <%=link("Reference.oil.readfrom")%> and <%=link("Reference.oil.writeto")%>.
- New parameter to define IDL include paths in IDL parsing functions (see <%=link("Reference.orb:loadidl")%> and <%=link("Reference.orb:loadidlfile")%>)
- It is not necessary to invoke <%=link"Reference.orb:run"%> to start processing incoming requests with brokers with multithreding support (i.e. flavor contains word
cooperative
).
- Operation <%=link"Reference.orb:shutdown"%> must be called before the application ends.
Otherwise an internal thread that process incoming requests will keep executing and the application will not terminate even if all other application threads terminate.
- Removed/Deprecated Features
-
- Field
oil.tasks
was replaced by module cothread
.
- Function
oil.pcall
was replaced by standard <%=link("LuaManual.pcall")%> function.
- Method
orb:tostring
was replaced by standard <%=link("LuaManual.tostring")%> function.
- CORBA configuration options were removed:
- Bug Fixes
-
- Bugfix to avoid parsing alphanumeric constant on IDL as numeric.
- Bugfix to avoid that <%link("Reference.orb:run")%> fails due to error on establishing incomming connection from bogus remote clients.
- Bugfix in parsing of IDL constants.
- Bugfix to allow
typedef
definitions of ValueTypes in IDL.
- Bugfix to avoid creation of servants with interface
CORBA::Object
.
- Bugfix to avoid creation of servants with abstract interfaces.
- Bugfix to avoid sending values marshaled as abstract valuetypes.
- Bugfix to catch LuDO mashaling errors.
- Bugfix to allow client interceptors to forward invocations in the 'receivereply' operation.
- Bugfix to capture errors raised in the CORBA interceptor methods and forward them to the application as servant errors.
- Bugfix to allow that operation descriptors of attribute functions (
_get_*
and _set_*
) have a field defined_in
with the interface the attribute is defined.
This is used in the CORBA interception mechanism to provide the interface where the attribute is defined.
- Bugfix to allow a CORBA server interceptor to send a service context to the client in a cancelled request.
- Bugfix to avoid index operations with the name of IDL attributes in proxies.
- Bugfix to avoid stop processing channels that receive message of a unsupported GIOP version.
- Bugfix to sinalize error on corbaloc parsing.
- Bugfix to avoid unecessary DNS lookups on IP addresses, because LuaSocket's 'socket.dns.toip' causes DNS lookups to obtain information not used by OiL when resolving connections.
- Bugfix to avoid that bogus RMI (GIOP) messages halt the processing of incomming requests.
- Bugfix in LuaIDL to output the proper type information of multiple attributes declared in one single line declaration.
- Bugfix to provide the proper minor code when an expected exception is caught by the ORB during a request dispatch.
- Bugfix to allow marshalling of numbers as enumerations.
- Bugfix to avoid that multiple connections to a same destination when there are simultaneous threads performing invocations to the same destination.
- Bugfix to avoid get a erro due to missing packages when 'package.path' contains a pattern without a '?'.


I'm having some trouble tracking this down, but I believe that httpclient 4.2.3 is clearing the interrupt flag.
My code looks like this: executorService.submit(new Runnable() { @Override public void run() { while (!Thread.currentThread().isInterrupted()) { consume(); // calls AWS SDK which uses Apache HttpClient } } }); Sometimes this loop does not terminate when calling Future.cancel(true). The only piece of diagnostics I have so far is this: Exception 'java.lang.InterruptedException' occurred in thread 'queue-consumer-reader-thread-1' at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2017) Exception 'java.lang.InterruptedException' occurred in thread 'queue-consumer-reader-thread-1' at org.apache.http.impl.conn.tsccm.WaitingThread.await(WaitingThread.java:164) Exception 'java.lang.InterruptedException' occurred in thread 'queue-consumer-reader-thread-1' at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:410) Exception 'java.lang.InterruptedException' occurred in thread 'queue-consumer-reader-thread-1' at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:423) Should I not expect the interrupt flag to be preserved? Do you have any suggestions how I could isolate this bug (I'm not 100% sure if it's in HttpClient or AWS client right now)? Thanks --------------------------------------------------------------------- To unsubscribe, e-mail<EMAIL_ADDRESS>For additional commands, e-mail: httpclient-users-h...@hc.apache.org


HOME
Variable naming conventions
JavaScript Variable Names
While naming your variables in JavaScript, keep the following rules in mind.
- You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.
- JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or an underscore character. For example, 123test is an invalid variable name but _123test is a valid one.
- JavaScript variable names are case-sensitive. For example, Name and name are two different variables.


1. JOIN
Create a profile. Don't be shy!
talk about your favourite writers and
the books that changed your life
Your profile will help you meet
people with similar interests and
find new literature to be
inspired and intrigued
2. R'n'R
Request your best next
read. Members from the
community can share it
with you.
Roll out the love!
3. CHAT
Join the conversation!
You can join the book chat and
share your thoughts and feelings.


Facets can be used to easily implement a way for users to filter a set of data, allowing them to apply and remove conditions. Facet selection components are usually contained within a Facet Container component. A Facet Container provides an overall view of all facets that are applied, and allows the user to quickly remove an individual facet, or all facets, without having to go through each facet selection component.
To add a Facet Container component to your application you need to import the FacetsModule
which allows
the use of the ux-facet-container
component.
The following attributes can be used to customise the behavior of the component:
FacetSelect
, FacetDeselect
or FacetDeselectAll
and will contain the facet being selected or deselected in a facet
property
(deselect all will not contain affected facets).
A facet object can contain the following properties:
These properties can be defined by passing the values to the constructor in the order listed above.
To customize the "Clear All" button add the *uxFacetClearButton
structural directive to an element within the
ux-facet-container
element, e.g:
The following code will produce the example shown above:


| Files | Events |
|---|---|
|
|
|
Invert colors:
Hide axes:
Show information dialogs:
Show display statistics:
Set maximum frame rate: fps
A browser-based event display for the CMS experiment at the LHC using WebGL.
Contributors: L. Barnard, M. Hategan, C. Logren, T. McCauley, P. Nguyen, M. Saunby
This view is specifically designed for use in a Google Cardboard viewer and therefore requires a viewer and a suitable mobile phone.
To use with the viewer, rotate the phone to landscape, press the button below, and insert into the viewer. The view automatically pans forward in the direction of view. To exit, tap the screen.
Select a 3D model to load.
Currently only .obj format is supported. If an additional .mtl is available and loaded it will be used as well.
Nota bene: a large complicated 3D model may take minutes to load.
Want to know more? Go here.
| Type | Value |
|---|


Recipe 4.17. Finding Unions and Intersections of Dictionaries
Credit: Tom Good, Andy McKay, Sami Hangaslammi, Robin
Siebler
Problem
Given two dictionaries, you
need to find the set of keys that are in both
dictionaries (the intersection) or the set of keys that are in
either dictionary (the union).
Solution
Sometimes, particularly in Python 2.3, you find yourself using
dictionaries as concrete representations of sets. In such cases, you
only care about the keys, not the corresponding values, and often you
build the dictionaries by calls to dict.fromkeys,
such as
a = dict.fromkeys(xrange(1000))
b = dict.fromkeys(xrange(500, 1500))
The fastest way to compute the dict that is the
set-union is:
union = dict(a, **b)
The fastest concise way to compute the dict that
is the set-intersection is:
inter = dict.fromkeys([x for x in a if x in b])
If the number of items in
dictionaries a and
b can be very different, then it can be
important for speed considerations to have the shorter one in the
for clause, and the longer one in the
if clause, of this list comprehension. In such
cases, it may be worth sacrificing some conciseness in favor of
speed, by coding the intersection computation as follows:
if len(a) < len(b):
inter = dict.fromkeys([x for x in a if x not in b])
else:
inter = dict.fromkeys([x for x in b if x not in a])
Python also gives
you types to represent sets directly (in standard library module
sets, and, in Python 2.4, also as built-ins). Here
is a snippet that you can use at the start of a module: the snippet
ensures that name set is bound to the best
available set type, so that throughout the module, you can then use
the same code whether you're using Python 2.3 or
2.4:
try:
set
except NameError:
from sets import Set as set
Having done this, you can now use type set to best
effect, gaining clarity and conciseness, and (in Python 2.4) gaining
a little speed, too:
a = set(xrange(1000))
b = set(xrange(500, 1500))
union = a | b
inter = a & b
Discussion
In Python 2.3,
even though the Python Standard Library module
sets offers an elegant data type
Set that directly represents a set (with hashable
elements), it is still common to use a dict to
represent a set, partly for historical reasons. Just in case you want
to keep doing it, this recipe shows you how to compute unions and
intersections of such sets in the fastest ways, which are not
obvious. The code in this recipe, on my machine, takes about 260
microseconds for the union, about 690 for the intersection (with
Python 2.3; with Python 2.4, 260 and 600,respectively), while
alternatives based on loops or generator expressions are
substantially slower.
However, it's best to use type
set instead of representing sets by dictionaries.
As the recipe shows, using set makes your code
more direct and readable. If you dislike the or-operator
(|) and the
"and-operator"
(&), you can equivalently use
a.union(b) and
a.intersection(b), respectively. Besides clarity,
you also gain speed, particularly in Python 2.4: computing the union
still takes about 260 microseconds, but computing the intersection
takes only about 210. Even in Python 2.3, this approach is acceptably
fast: computing the union takes about 270 microseconds, computing the
intersection takes about 650not quite as fast as Python 2.4
but still quite comparable to what you can get if you represent sets
by dictionaries. Last but not least, once you use type
set (whether it is the Python 2.4 built-in, or
class Set from the Python Standard Library module
sets, the interface is the same), you gain a
wealth of useful set operations. For example, the set of elements
that are in either a or
b but not both is a^b
or, equivalently, a.symmetric_difference(b).
Even if you start with dicts for other reasons,
consider using sets anyway if you need to perform
set operations. Say, for example, that you have in
phones a dictionary that maps names to
phone numbers and in addresses one that
maps names to addresses. The clearest and simplest way to print all
names for which you know both address and phone number, and their
associated data, is:
for name in set(phones) & set(addresses):
print name, phones[name], addresses[name]
This is much terser, and arguably clearer, than something like:
for name in phones:
if name in addresses:
print name, phones[name], addresses[name]
Another excellent alternative is:
for name in set(phones).intersection(addresses):
print name, phones[name], addresses[name]
If you
use the named intersection method, rather than the
& intersection operator, you
don't need to turn both dicts
into sets: just one of them. Then call
intersection on the resulting
set, and pass the other dict as
the argument to the intersection method.
See Also
The Library Reference and Python in
a Nutshell sections on mapping types, module
sets, and Python 2.4's built-in
set type.
|


Keeping in mind these basic rotations :
Please try to fill the right rotations required to pass from figure 1 to figure 2. The highlighted axis are always looking OUT of the page (Towards you).
Please enter values such as "cos 90", "-sin 90", "sin -90", "-cos -90", "sin 90 + cos -180" or "cos 90 * cos -90", do not actually calculate them and make sure to not leave any spaces.