7#include "arcane/geometry/impl/GeometryServiceBase.h"
12#include "arcane/core/IMesh.h"
15#include "arcane/core/IItemOperationByBasicType.h"
16#include "arcane/core/IItemFamily.h"
17#include "arcane/core/ArcaneVersion.h"
18#include "arcane/core/ItemVectorView.h"
25namespace Arcane::Numerics
50 properties.defined |= property;
53 if (property & current_property) {
54 properties.storages[
static_cast<IGeometryProperty::eProperty
>(current_property)].storageType |= storage;
56 << IGeometryProperty::name(
static_cast<IGeometryProperty::eProperty
>(current_property))
57 <<
"] on group " << group.
name();
59 property &= ~current_property;
60 current_property <<= 1;
67 ARCANE_ASSERT((IGeometryProperty::isScalar(property)), (
"Scalar property expected"));
70 if (storage.realVar) {
71 if (storage.realVar->name() != var.
name())
72 traceMng()->
fatal() <<
"Geometric property [" << IGeometryProperty::name(property)
73 <<
"] storage already defined on group " << group.
name()
74 <<
" with variable " << storage.realVar->name();
75 ARCANE_ASSERT((properties.defined & property), (
"Unconsistent state with undefined property with defined variable"));
78 properties.defined |= property;
79 storage.realVar.reset(
new RealVariable(var));
80 storage.storageType |= IGeometryProperty::PVariable;
81 storage.externStorage |= IGeometryProperty::PVariable;
92 ARCANE_ASSERT((IGeometryProperty::isVectorial(property)), (
"Vectorial property expected"));
95 if (storage.real3Var) {
96 if (storage.real3Var->name() != var.
name())
97 traceMng()->
fatal() <<
"Geometric property [" << IGeometryProperty::name(property)
98 <<
"] storage already defined on group " << group.
name()
99 <<
" with variable " << storage.real3Var->name();
100 ARCANE_ASSERT((properties.defined & property), (
"Unconsistent state with undefined property with defined variable"));
103 properties.defined |= property;
104 storage.real3Var.reset(
new Real3Variable(var));
105 storage.storageType |= IGeometryProperty::PVariable;
106 storage.externStorage |= IGeometryProperty::PVariable;
118 PropertyMap::const_iterator iprop = m_group_property_map.find(group.
internal());
119 if (iprop == m_group_property_map.end())
120 return IGeometryProperty::PNone;
121 return iprop->second.defined;
134 PropertyMap::const_iterator iprop = m_group_property_map.find(group.
internal());
135 if (iprop == m_group_property_map.end())
136 return IGeometryProperty::PNoStorage;
137 return iprop->second.getStorage(property);
142const IGeometryMng::RealVariable&
146 if (!IGeometryProperty::isScalar(property))
147 traceMng()->
fatal() <<
"Non scalar property requested by scalar interface";
149 std::shared_ptr<RealVariable>& pvar = storage.realVar;
152 storage.usageVarCount++;
156const IGeometryMng::Real3Variable&
160 if (!IGeometryProperty::isVectorial(property))
161 traceMng()->
fatal() <<
"Non vectorial property requested by vectorial interface";
163 std::shared_ptr<Real3Variable>& pvar = storage.real3Var;
166 storage.usageVarCount++;
193 _checkItemGroupUsage();
194 _resetComputeFlags();
201 for (
Integer ikind = 0; ikind < all_kind_size; ++ikind) {
202 const eItemKind current_kind = all_kinds[ikind];
206 if (m_group_property_map.find(allItemGroup.
internal()) != m_group_property_map.end()) {
211 for (PropertyMap::iterator igroup = m_group_property_map.begin(); igroup != m_group_property_map.end(); ++igroup) {
213 if (group.
itemKind() == current_kind) {
215 for (ItemGroupGeometryProperty::StorageInfos::const_iterator iprop = group_property.storages.begin();
216 iprop != group_property.storages.end(); ++iprop) {
217 const IGeometryProperty::eProperty
property = iprop->first;
220 if (property & all_group_property.defined)
223 if (IGeometryProperty::isScalar(property)) {
224#ifndef NO_USER_WARNING
225#warning "failed when ItemGroupMap storage only on allItems group"
227 RealVariable& var = *all_group_property.storages[property].realVar;
230 if (storage.storageType & IGeometryProperty::PVariable) {
231 if (storage.externStorage & IGeometryProperty::PVariable) {
232 RealVariable& lvar = *storage.realVar;
234 lvar[iitem] = var[iitem];
238 std::shared_ptr<RealVariable>& lvar = storage.realVar;
240 if (lvar->variable() != var.
variable()) {
242 lvar.reset(
new RealVariable(var));
248 lvar.reset(
new RealVariable(var));
254 group_property.computed |= property;
255 group_property.delegated |= property;
258 ARCANE_ASSERT((IGeometryProperty::isVectorial(property)), (
"Vectorial property expected"));
259 Real3Variable& var = *all_group_property.storages[property].real3Var;
262 if (storage.storageType & IGeometryProperty::PVariable) {
263 if (storage.externStorage & IGeometryProperty::PVariable) {
264 Real3Variable& lvar = *storage.real3Var;
266 lvar[iitem] = var[iitem];
270 std::shared_ptr<Real3Variable>& lvar = storage.real3Var;
272 if (lvar->variable() != var.
variable()) {
274 lvar.reset(
new Real3Variable(var));
280 lvar.reset(
new Real3Variable(var));
286 group_property.computed |= property;
287 group_property.delegated |= property;
297 for (PropertyMap::iterator iprop = m_group_property_map.begin(); iprop != m_group_property_map.end(); ++iprop) {
305 for (PropertyMap::iterator iprop = m_group_property_map.begin(); iprop != m_group_property_map.end(); ++iprop) {
315 IGeometryProperty::eProperty property,
316 IGeometryProperty::eStorage storage)
318 PropertyMap::iterator iprop = m_group_property_map.find(group);
319 if (iprop == m_group_property_map.end())
322 if ((properties.defined & property) != property)
323 ARCANE_FATAL(
"Non available property [{0}] requested from group {1}",
324 IGeometryProperty::name(property), group->
name());
326 if ((storages.storageType & storage) != storage)
327 ARCANE_FATAL(
"Non available storage [{0}] requested for property {1} on group {2}",
328 IGeometryProperty::name(storage), IGeometryProperty::name(property), group->
name());
335void GeometryServiceBase::_resetComputeFlags()
337 for (PropertyMap::iterator igroup = m_group_property_map.begin(); igroup != m_group_property_map.end(); ++igroup) {
339 group_property.resetFlags();
346void GeometryServiceBase::_checkItemGroupUsage()
349 typedef std::map<const IVariable*, std::pair<ItemGroupImpl*, IGeometryProperty::eProperty>> ExternVariables;
350 ExternVariables extern_variables;
352 for (PropertyMap::iterator igroup = m_group_property_map.begin(); igroup != m_group_property_map.end(); ++igroup) {
354 for (ItemGroupGeometryProperty::StorageInfos::const_iterator i = group_property.storages.begin();
355 i != group_property.storages.end(); ++i) {
356 const IGeometryProperty::eProperty
property = i->first;
358 if (info.usageVarCount == 0 && (info.realVar || info.real3Var) && !(info.externStorage & IGeometryProperty::PVariable))
359 traceMng()->
warning() <<
"Geometric property " << IGeometryProperty::name(property)
360 <<
" on group " << igroup->first->name() <<
" with Variable storage never used since last update";
363 if (info.realVar || (info.real3Var && (info.externStorage & IGeometryProperty::PVariable))) {
366 check_variable = info.realVar->variable();
369 ARCANE_ASSERT((check_variable == NULL), (
"Inconsistent real/real3 storage"));
370 check_variable = info.real3Var->variable();
372 std::map<const IVariable*, std::pair<ItemGroupImpl*, IGeometryProperty::eProperty>>::const_iterator finder = extern_variables.find(check_variable);
373 if (finder != extern_variables.end()) {
374 traceMng()->
warning() <<
"Geometric property " << IGeometryProperty::name(property)
375 <<
" on group " << igroup->first->name()
376 <<
" shares extern Variable " << finder->first->name()
377 <<
" with property " << IGeometryProperty::name(finder->second.second)
378 <<
" on group " << finder->second.first->name();
381 extern_variables[check_variable] = std::make_pair(igroup->first, property);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Exception when a fatal error has occurred.
Interface of an entity family.
virtual ItemGroup allItems() const =0
Group of all entities.
virtual TraceMessage warning()=0
Stream for a warning message.
virtual TraceMessage fatal()=0
Stream for a fatal error message.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Stream for a debug message.
Brief: Implementation of a mesh entity group.
const String & name() const
Group name.
ItemGroupImpl * internal() const
Returns the group implementation.
const String & name() const
Group name.
eItemKind itemKind() const
Group kind. This is the kind of its elements.
String m_suffix
suffix for internal variable names
Integer getItemGroupProperty(ItemGroup group)
Get set of properties of an ItemGroup.
void addItemGroupProperty(ItemGroup group, Integer property, Integer storage=IGeometryProperty::PVariable)
Set geometric properties on an ItemGroup.
virtual IMesh * mesh()=0
Access to mesh.
void reset()
Reset property for all ItemGroups.
virtual const char * className() const =0
Name of instantiated class.
virtual ITraceMng * traceMng()=0
Access to traceMng.
const Real3Variable & getReal3VariableProperty(ItemGroup group, IGeometryProperty::eProperty property)
Get geometric property values for a Real3 field.
bool hasItemGroupProperty(ItemGroup group, Integer property)
Check if a property is activated on an ItemGroup.
Integer getItemGroupPropertyStorage(ItemGroup group, IGeometryProperty::eProperty property)
Check if storage is available on an ItemGroup.
virtual ~GeometryServiceBase()
const RealVariable & getRealVariableProperty(ItemGroup group, IGeometryProperty::eProperty property)
Get geometric property values for a Real field.
void update()
Update property values for all ItemGroups.
ItemGroupGeometryProperty::StorageInfo & _checkItemGroupProperty(ItemGroupImpl *group, IGeometryProperty::eProperty property, IGeometryProperty::eStorage storage)
Return ItemGroupGeometryProperty if requested property and storage are available.
Internal class implementation for TemisGeometryService and Euclidian3GeometryService.
Unicode character string.
IVariable * variable() const
Associated variable.
String name() const
Variable name.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
eItemKind
Mesh entity type.
@ IK_Cell
Cell mesh entity.
@ IK_Face
Face mesh entity.