changed doc strings

This commit is contained in:
Jukka Aho
2015-06-20 16:55:25 +03:00
parent b8cd233f3c
commit 9e0e6b622f
+89 -64
View File
@@ -1,9 +1,12 @@
# This file is a part of JuliaFEM. License is MIT: https://github.com/ovainola/JuliaFEM/blob/master/README.md # This file is a part of JuliaFEM. License is MIT: https://github.com/ovainola/JuliaFEM/blob/master/README.md
module JuliaFEM module JuliaFEM
export Model, new_model, new_field, get_field export Model, new_model, new_field, get_field, add_nodes, get_nodes
@doc """
Basic model
""" ->
type Model type Model
model # For global variables model # For global variables
nodes # For nodes nodes # For nodes
@@ -12,52 +15,71 @@ type Model
element_gauss_points # For element gauss points element_gauss_points # For element gauss points
end end
@doc """
Initialize empty model.
Parameters
----------
None
Returns
-------
New model struct
""" ->
function new_model() function new_model()
"""Initialize empty model.
"""
return Model(Dict(), Dict(), Dict(), Dict(), Dict()) return Model(Dict(), Dict(), Dict(), Dict(), Dict())
end end
@doc """
Create new field to model.
Parameters
----------
field_type : Dict()
Target topology (model.model, model.nodes, model.elements,
model.element_nodes, model.element_gauss
field_name : str
Field name
Returns
-------
Dict
New field
""" ->
function new_field(field_type, field_name) function new_field(field_type, field_name)
"""Create new field to model.
Parameters
----------
field_type : Dict()
Target topology (model.model, model.nodes, model.elements,
model.element_nodes, model.element_gauss
field_name : str
Field name
Returns
-------
Dict
New field
"""
d = Dict() d = Dict()
setindex!(field_type, d, field_name) setindex!(field_type, d, field_name)
return d return d
end end
@doc """Get field from model.
Parameters
----------
field_type : Dict()
Target topology (model.model, model.nodes, model.elements,
model.element_nodes, model.element_gauss
field_name : str
Field name
create_if_doesnt_exist : bool, optional
If field doesn't exists, create one and return empty field
Raises
------
Error, if field not found and create_if_doesnt_exist == false
""" ->
function get_field(field_type, field_name; create_if_doesnt_exist=false) function get_field(field_type, field_name; create_if_doesnt_exist=false)
"""Get field from model.
Parameters
----------
field_type : Dict()
Target topology (model.model, model.nodes, model.elements,
model.element_nodes, model.element_gauss
field_name : str
Field name
create_if_doesnt_exist : bool, optional
If field doesn't exists, create one and return empty field
Raises
------
Error, if field not found and create_if_doesnt_exist == false
"""
if !(field_name in keys(field_type)) if !(field_name in keys(field_type))
if create_if_doesnt_exist if create_if_doesnt_exist
field = new_field(field_type, field_name) field = new_field(field_type, field_name)
@@ -71,23 +93,24 @@ function get_field(field_type, field_name; create_if_doesnt_exist=false)
end end
@doc """Add new nodes to model.
Parameters
----------
nodes : Dict()
id => coords
Returns
-------
model
Notes
-----
Create new field "coords" to model if not found
""" ->
function add_nodes(model, nodes) function add_nodes(model, nodes)
"""Add new nodes to model.
Parameters
----------
nodes : Dict()
id => coords
Returns
-------
model
Notes
-----
Create new field "coords" to model if not found
"""
println("Adding ", length(nodes), " nodes to model") println("Adding ", length(nodes), " nodes to model")
field = get_field(model.nodes, "coords"; create_if_doesnt_exist=true) field = get_field(model.nodes, "coords"; create_if_doesnt_exist=true)
for (node_id, coords) in nodes for (node_id, coords) in nodes
@@ -96,19 +119,21 @@ function add_nodes(model, nodes)
end end
@doc """Return subset of nodes from model.
Parameters
----------
node_ids : array
list of node ids to return
Returns
-------
Dict()
id => coords
""" ->
function get_nodes(model, node_ids) function get_nodes(model, node_ids)
"""Return subset of nodes from model.
Parameters
----------
node_ids : array
list of node ids to return
Returns
-------
Dict()
id => coords
"""
subset = Dict() subset = Dict()
for node_id in node_ids for node_id in node_ids
subset[node_id] = model.nodes["coords"][node_id] subset[node_id] = model.nodes["coords"][node_id]