v0.16.3
Loading...
Searching...
No Matches
Static Public Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
MatOps::MatOpsTagsRegistry Struct Reference

#include "src/materials/MatOps.hpp"

Collaboration diagram for MatOps::MatOpsTagsRegistry:
[legend]

Static Public Member Functions

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

Static Protected Member Functions

static int getTagByName (std::string name)
 

Static Protected Attributes

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

Detailed Description

Definition at line 24 of file MatOps.hpp.

Member Function Documentation

◆ atTagName()

int MatOps::MatOpsTagsRegistry::atTagName ( std::string  name)
static
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 25 of file MatOps.cpp.

25 {
26 return tagNameVsTag.at(name);
27}
static std::map< std::string, int > tagNameVsTag
Definition MatOps.hpp:32

◆ getTagByName()

int MatOps::MatOpsTagsRegistry::getTagByName ( std::string  name)
staticprotected
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 80 of file MatOps.cpp.

80 {
81 auto it = tagNameVsTag.find(name);
82 if (it == tagNameVsTag.end()) {
83 int new_tag = tagNameVsTag.size() + 1;
84 tagNameVsTag[name] = new_tag;
85 return new_tag;
86 }
87 return it->second;
88}

◆ getTagName()

std::string MatOps::MatOpsTagsRegistry::getTagName ( int  tag)
static
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 90 of file MatOps.cpp.

90 {
91 for (const auto &p : tagNameVsTag) {
92 if (p.second == tag) {
93 return p.first;
94 }
95 }
96 return std::string();
97}

◆ setTagName()

int MatOps::MatOpsTagsRegistry::setTagName ( std::string  name,
int  tag = -1 
)
static
Examples
mofem/src/materials/MatOps.hpp, and mofem/tutorials/vec-2_nonlinear_elasticity/src/NonlinearElasticExample.hpp.

Definition at line 29 of file MatOps.cpp.

29 {
30#ifndef NDEBUG
31 MOFEM_LOG_CHANNEL("WORLD");
32#endif
33
34 auto it = tagNameVsTag.find(name);
35
36 if (tag >= 0) {
37 if (it != tagNameVsTag.end()) {
38#ifndef NDEBUG
39 MOFEM_LOG("WORLD", Sev::warning)
40 << "Tag name: " << name
41 << " is already registered with tag: " << it->second
42 << ". Overwriting with new tag: " << tag;
43#endif
44 it->second = -1; // set it to invalid value to avoid confusion
45 }
46#ifndef NDEBUG
47 for (auto &p : tagNameVsTag) {
48 if (p.second == tag) {
50 "Tag: " + std::to_string(tag) +
51 " is already registered with name: " + p.first);
52 }
53 }
54#endif
55 // register new tag
56 tagNameVsTag[name] = tag;
57 return tag;
58 }
59
60 int max_tag = 0;
61 for (auto &p : tagNameVsTag) {
62 if (p.second > max_tag) {
63 max_tag = p.second;
64 }
65 }
66
67 if (it == tagNameVsTag.end()) {
68 tagNameVsTag[name] = max_tag + 1;
69 }
70
71#ifndef NDEBUG
72 MOFEM_LOG("WORLD", Sev::inform)
73 << "Tag name: " << name
74 << " is registered with tag: " << tagNameVsTag[name];
75#endif
76
77 return tagNameVsTag[name];
78}
#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> MatOps::MatOpsTagsRegistry::tagNameVsTag
inlinestaticprotected
Examples
mofem/src/materials/MatOps.hpp.

Definition at line 32 of file MatOps.hpp.


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