OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
FieldSolverCmd.cpp
Go to the documentation of this file.
1//
2// Class FieldSolverCmd
3// The class for the OPAL FIELDSOLVER command.
4// A FieldSolverCmd definition is used by most physics commands to define the
5// particle charge and the reference momentum, together with some other data.
6//
7// Copyright (c) 200x - 2022, Paul Scherrer Institut, Villigen PSI, Switzerland
8//
9// All rights reserved
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
22
23#include <map>
30#include "Physics/Physics.h"
32
33using namespace Expressions;
34
35// TODO: o add a FIELD for DISCRETIZATION, MAXITERS, TOL...
36
38 : Definition(
39 FIELDSOLVER::SIZE, "FIELDSOLVER",
40 "The \"FIELDSOLVER\" statement defines data for a the field solver") {
42 "TYPE", "Name of the attached field solver.", {"NONE", "FFT", "CG ", "OPEN", "P3M"});
43
44 itsAttr[FIELDSOLVER::NX] = Attributes::makeReal("NX", "Meshsize in x");
45 itsAttr[FIELDSOLVER::NY] = Attributes::makeReal("NY", "Meshsize in y");
46 itsAttr[FIELDSOLVER::NZ] = Attributes::makeReal("NZ", "Meshsize in z");
47
49 Attributes::makeBool("PARFFTX", "True, dimension 0 i.e x is parallelized", false);
50
52 Attributes::makeBool("PARFFTY", "True, dimension 1 i.e y is parallelized", false);
53
55 Attributes::makeBool("PARFFTZ", "True, dimension 2 i.e z is parallelized", true);
56
58 "BCFFTX", "Boundary conditions in x.", {"OPEN", "DIRICHLET", "PERIODIC"}, "OPEN");
59
61 "BCFFTY", "Boundary conditions in y.", {"OPEN", "DIRICHLET", "PERIODIC"}, "OPEN");
62
64 "BCFFTZ", "Boundary conditions in z.", {"OPEN", "DIRICHLET", "PERIODIC"}, "OPEN");
65
67 "GREENSF", "Which Greensfunction to be used.", {"STANDARD", "INTEGRATED"}, "INTEGRATED");
68
70 Attributes::makeReal("BBOXINCR", "Increase of bounding box in % ", 2.0);
71
72 // \todo does not work registerOwnership(AttributeHandler::STATEMENT);
73}
74
75FieldSolverCmd::FieldSolverCmd(const std::string& name, FieldSolverCmd* parent)
76 : Definition(name, parent) {
77}
78
81
82FieldSolverCmd* FieldSolverCmd::clone(const std::string& name) {
83 return new FieldSolverCmd(name, this);
84}
85
90
91FieldSolverCmd* FieldSolverCmd::find(const std::string& name) {
92 FieldSolverCmd* fs = dynamic_cast<FieldSolverCmd*>(OpalData::getInstance()->find(name));
93
94 if (fs == 0) {
95 throw OpalException("FieldSolverCmd::find()", "FieldSolverCmd \"" + name + "\" not found.");
96 }
97 return fs;
98}
99
103
107
111
115
116void FieldSolverCmd::setNX(double value) {
118}
119
120void FieldSolverCmd::setNY(double value) {
122}
123
124void FieldSolverCmd::setNZ(double value) {
126}
127
131
132
135 fsName_m = getType();
136 }
137}
138
140 static const std::map<std::string, FieldSolverCmdType> stringType_s = {
141 {"NONE", FieldSolverCmdType::NONE},
143 };
144
145 fsName_m = getType();
146
147 if (fsName_m.empty()) {
148 throw OpalException(
149 "FieldSolverCmd::setFieldSolverCmdType",
150 "The attribute \"TYPE\" isn't set for \"FIELDSOLVER\"!");
151 } else {
152 fsType_m = stringType_s.at(fsName_m);
153 }
154}
155
157 return false;
158}
159
160Inform& FieldSolverCmd::printInfo(Inform& os) const {
161 os << "* ************* F I E L D S O L V E R ********************************************** "
162 << endl;
163 os << "* FIELDSOLVER " << getOpalName() << '\n'
164 << "* TYPE " << fsName_m << '\n'
165 << "* RANKS " << ippl::Comm->size() << '\n'
166 << "* NX " << Attributes::getReal(itsAttr[FIELDSOLVER::NX]) << '\n'
167 << "* NY " << Attributes::getReal(itsAttr[FIELDSOLVER::NY]) << '\n'
168 << "* NZ " << Attributes::getReal(itsAttr[FIELDSOLVER::NZ]) << '\n'
169 << "* BBOXINCR " << Attributes::getReal(itsAttr[FIELDSOLVER::BBOXINCR]) << '\n'
170 << "* GREENSF " << Attributes::getString(itsAttr[FIELDSOLVER::GREENSF]) << endl;
171
173 os << "* XDIM parallel " << endl;
174 } else {
175 os << "* XDIM serial " << endl;
176 }
177
179 os << "* YDIM parallel " << endl;
180 } else {
181 os << "* YDIM serial " << endl;
182 }
183
185 os << "* ZDIM parallel " << endl;
186 } else {
187 os << "* ZDIM serial " << endl;
188 }
189
190 os << "* ********************************************************************************** "
191 << endl;
192 return os;
193}
@ SIZE
Definition IndexMap.cpp:173
Representation objects and parsers for attribute expressions.
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
void setReal(Attribute &attr, double val)
Set real value.
std::string getString(const Attribute &attr)
Get string value.
Definition(int size, const char *name, const char *help)
Constructor for exemplars.
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:308
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
Object * find(const std::string &name)
Find entry.
Definition OpalData.cpp:563
static OpalData * getInstance()
Definition OpalData.cpp:195
virtual void execute()
Execute (init) the field solver data.
virtual FieldSolverCmd * clone(const std::string &name)
Make clone.
FieldSolverCmdType fsType_m
static FieldSolverCmd * find(const std::string &name)
Find named FieldSolverCmd.
Inform & printInfo(Inform &os) const
void setNZ(double)
FieldSolverCmd()
Exemplar constructor.
double getNX() const
Return meshsize.
std::string fsName_m
virtual ~FieldSolverCmd()
double getNY() const
Return meshsize.
double getNZ() const
Return meshsize.
virtual void update()
Update the field solver data.
double getBoxIncr() const
std::string getType()
void setNY(double)
void setNX(double)
The base class for all OPAL exceptions.