v0.15.5
Loading...
Searching...
No Matches
Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
AdolCOps::AdolCTagsRegistry Struct Reference

#include "src/adolc/AdolCOps.hpp"

Collaboration diagram for AdolCOps::AdolCTagsRegistry:
[legend]

Static Public Member Functions

static auto atTagName (std::string name)
 
static auto setTagName (std::string name, int tag=-1)
 

Static Private Member Functions

static int getTagByName (std::string name)
 

Static Private Attributes

static std::map< std::string, int > tagNameVsTag
 

Detailed Description

Definition at line 13 of file AdolCOps.hpp.

Member Function Documentation

◆ atTagName()

static auto AdolCOps::AdolCTagsRegistry::atTagName ( std::string  name)
inlinestatic

Definition at line 15 of file AdolCOps.hpp.

15{ return tagNameVsTag.at(name); }
static std::map< std::string, int > tagNameVsTag
Definition AdolCOps.hpp:70

◆ getTagByName()

static int AdolCOps::AdolCTagsRegistry::getTagByName ( std::string  name)
inlinestaticprivate

Definition at line 60 of file AdolCOps.hpp.

60 {
61 auto it = tagNameVsTag.find(name);
62 if (it == tagNameVsTag.end()) {
63 int new_tag = tagNameVsTag.size() + 1;
64 tagNameVsTag[name] = new_tag;
65 return new_tag;
66 }
67 return it->second;
68 }

◆ setTagName()

static auto AdolCOps::AdolCTagsRegistry::setTagName ( std::string  name,
int  tag = -1 
)
inlinestatic
Examples
mofem/tutorials/vec-2_nonlinear_elasticity/src/NonlinearElasticExample.hpp.

Definition at line 16 of file AdolCOps.hpp.

16 {
17 MOFEM_LOG_CHANNEL("WORLD");
18
19 auto it = tagNameVsTag.find(name);
20
21 if (tag >= 0) {
22 if (it != tagNameVsTag.end()) {
23 MOFEM_LOG("WORLD", Sev::warning)
24 << "Tag name: " << name
25 << " is already registered with tag: " << it->second
26 << ". Overwriting with new tag: " << tag;
27 it->second = -1; // set it to invalid value to avoid confusion
28 }
29 for (auto &p : tagNameVsTag) {
30 if (p.second == tag) {
32 "Tag: " + std::to_string(tag) +
33 " is already registered with name: " + p.first);
34 }
35 }
36 // register new tag
37 tagNameVsTag[name] = tag;
38 return tag;
39 }
40
41 int max_tag = 0;
42 for (auto &p : tagNameVsTag) {
43 if (p.second > max_tag) {
44 max_tag = p.second;
45 }
46 }
47
48 if (it == tagNameVsTag.end()) {
49 tagNameVsTag[name] = max_tag + 1;
50 }
51
52 MOFEM_LOG("WORLD", Sev::inform)
53 << "Tag name: " << name
54 << " is registered with tag: " << tagNameVsTag[name];
55
56 return tagNameVsTag[name];
57 }
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.

Member Data Documentation

◆ tagNameVsTag

std::map<std::string, int> AdolCOps::AdolCTagsRegistry::tagNameVsTag
inlinestaticprivate

Definition at line 70 of file AdolCOps.hpp.


The documentation for this struct was generated from the following file: