21 #include "SheafSystem/body_factory.h" 23 #include "SheafSystem/arg_list.h" 24 #include "SheafSystem/assert_contract.h" 25 #include "SheafSystem/array_index_space_state.h" 26 #include "SheafSystem/base_space_member.h" 27 #include "SheafSystem/block.impl.h" 28 #include "SheafSystem/body_builder.h" 29 #include "SheafSystem/fiber_bundles_namespace.h" 30 #include "SheafSystem/field_factory.h" 31 #include "SheafSystem/std_cmath.h" 32 #include "SheafSystem/std_iostream.h" 33 #include "SheafSystem/std_sstream.h" 34 #include "SheafSystem/field_vd.h" 35 #include "SheafSystem/wsv_block.impl.h" 51 const std::string& xname_prefix)
56 require(!xns.
contains_poset(xname_prefix+
"_1d_unstructured_base_space"));
67 field_factory::new_scalar_field_1d_unstructured(xns,
68 xname_prefix+
"_1d_unstructured",
76 build_bodies(*result);
92 const std::string& xname_prefix)
97 require(!xns.
contains_poset(xname_prefix+
"_1d_uniform_base_space"));
108 field_factory::new_scalar_field_1d_uniform(xns,
109 xname_prefix+
"_1d_uniform",
117 build_bodies(*result);
134 const std::string& xname_prefix)
139 require(!xns.
contains_poset(xname_prefix+
"_2d_unstructured_base_space"));
150 field_factory::new_scalar_field_2d_unstructured(xns,
151 xname_prefix+
"_2d_unstructured",
161 build_bodies(*result);
177 const std::string& xname_prefix)
182 require(!xns.
contains_poset(xname_prefix+
"_2d_uniform_base_space"));
193 field_factory::new_scalar_field_2d_uniform(xns,
194 xname_prefix+
"_2d_uniform",
203 build_bodies(*result);
219 const std::string& xname_prefix)
224 require(!xns.
contains_poset(xname_prefix+
"_3d_unstructured_base_space"));
235 field_factory::new_scalar_field_3d_unstructured(xns,
236 xname_prefix+
"_3d_unstructured",
247 build_bodies(*result);
263 const std::string& xname_prefix)
268 require(!xns.
contains_poset(xname_prefix+
"_3d_uniform_base_space"));
279 field_factory::new_scalar_field_3d_uniform(xns,
280 xname_prefix+
"_3d_uniform",
290 build_bodies(*result);
307 fields::body_factory::
313 require(xproperty_value.
ct() == 1);
320 for(
int i= 0; i<xglobal_coords.
ct(); ++i)
322 lprop_val0 += xglobal_coords[i]*xglobal_coords[i];
325 lprop_val0 =
sqrt(lprop_val0);
329 ensure(xproperty_value[0] >= 0.0);
337 fields::body_factory::
343 require(xglobal_coords.
ct() > 0);
345 require(xproperty_value.
ct() == 1);
349 int ldc = xglobal_coords.
ct();
350 bool linside = (
fabs(xglobal_coords[0]) >= .5);
351 if(linside && (ldc > 1))
353 linside = (
fabs(xglobal_coords[1]) <= 0.5);
355 if(linside && (ldc > 2))
357 linside = (
fabs(xglobal_coords[2]) <= 0.5);
363 xproperty_value[0] = 1.0;
367 xproperty_value[0] = 0.0;
378 fields::body_factory::
379 build_circular_body(
field_vd& xfield)
381 #ifdef DIAGNOSTIC_OUTPUT 382 cout <<
"entering body_factory::build_circular_body:" << endl;
389 subposet lbodies(lbase_space_host,
"bodies");
394 *lbody_builder.
build(xfield, -0.1, 0.5);
396 for(
int i=0; i<lcircular_bodies.
ct(); ++i)
399 lstr <<
"circular_body" << i;
409 #ifdef DIAGNOSTIC_OUTPUT 410 cout << endl <<
"circular bodies (should be exactly one):";
411 for(
int i=0; i<lcircular_bodies.
ct(); ++i)
413 cout <<
" " << lcircular_bodies[i];
424 delete &lcircular_bodies;
426 #ifdef DIAGNOSTIC_OUTPUT 427 cout <<
"leaving body_factory::build_circular_body:" << endl;
434 fields::body_factory::
435 build_square_bodies(
field_vd& xfield)
437 #ifdef DIAGNOSTIC_OUTPUT 438 cout <<
"entering body_factory::build_square_bodies:" << endl;
445 subposet lbodies(lbase_space_host,
"bodies");
450 *lbody_builder.
build(xfield, 0.9, 1.1);
452 for(
int i=0; i<lsquare_bodies.
ct(); ++i)
455 lstr <<
"square_body" << i;
465 #ifdef DIAGNOSTIC_OUTPUT 466 cout << endl <<
"square bodies (should be exactly two):";
467 for(
int i=0; i<lsquare_bodies.
ct(); ++i)
469 cout <<
" " << lsquare_bodies[i];
480 delete &lsquare_bodies;
482 #ifdef DIAGNOSTIC_OUTPUT 483 cout <<
"leaving body_factory::build_square_bodies:" << endl;
490 fields::body_factory::
497 subposet lbodies(lbase_space_host, 0,
false);
498 lbodies.
put_name(
"bodies",
true,
false);
503 build_circular_body(xfield);
511 build_square_bodies(xfield);
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
A client handle for a subposet.
size_type ct() const
The number of items currently in use.
Namespace for fields component of sheaf system.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
virtual void get_read_access() const
Get read access to the state associated with this.
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
static field_vd * new_2d_uniform_bodies(fiber_bundles_namespace &xns, const std::string &xname_prefix)
Uses body_builder to create bodies in a 2D uniform mesh.
virtual void put_member_name(pod_index_type xmbr_hub_id, const std::string &xname, bool xunique, bool xauto_access=false)
Make xname a name for the member with hub id xmbr_hub_id. if xunique, make xname the only name...
virtual void put_name(const std::string &xname, bool xunique, bool xauto_access)
Make xname a name for this; if xunique, make xname the only name.
static field_vd * new_3d_unstructured_bodies(fiber_bundles_namespace &xns, const std::string &xname_prefix)
Uses body_builder to create bodies in a 3D unstructured mesh.
A client handle for a mutable partially ordered set.
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
poset * host() const
The poset which this is a handle to a member of.
virtual scattered_insertion_index_space_handle & new_id_space(const std::string &xstate_class_name)
Creates an id space for the members of this.
An index within the external ("client") scope of a given id space.
virtual void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
A vd-valued property as a function of global coordinates.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
static field_vd * new_3d_uniform_bodies(fiber_bundles_namespace &xns, const std::string &xname_prefix)
Uses body_builder to create bodies in a 3D uniform mesh.
SHEAF_DLL_SPEC void fabs(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute fabs of x0 (fabs(x0)) (pre-allocated version).
static field_vd * new_2d_unstructured_bodies(fiber_bundles_namespace &xns, const std::string &xname_prefix)
Uses body_builder to create bodies in a 2D unstructured mesh.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
base_space_member & base_space() const
The base space of this field.
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
const scattered_insertion_index_space_handle & id_space() const
The id space for the members of with this (const version).
virtual void detach_from_state()
Detach this handle from its state, if any.
void put_property_dofs(property_dof_function_type xproperty_dofs_fcn, bool xauto_access)
Sets the dofs of property() to values computed by xproperty_dofs_fcn.
static field_vd * new_1d_uniform_bodies(fiber_bundles_namespace &xns, const std::string &xname_prefix)
Uses body_builder to create bodies in a 1D uniform mesh.
A handle for a scattered_insertion_index_space_state.
void push_back(const scoped_index &xhub_id)
Make the next id in this space equivalent to xhub_id in the hub id space. synonym for push_back(xhub_...
block< scoped_index > * build(field_vd &xfield, value_type xlower, value_type xupper)
Builds the bodies defined by threshholds xlower and xupper in field xfield; auto_allocated.
static field_vd * new_1d_unstructured_bodies(fiber_bundles_namespace &xns, const std::string &xname_prefix)
Uses body_builder to create bodies in a 1D unstructured mesh.
vd_value_type sec_vd_value_type
The type of component in the value of a section at a point.
A simple body builder; creates base space members equivalent to subsets defined by a field classifica...